''--------------------------------------------------------Start
Imports System:Imports System.ComponentModel
Imports System.Data:Imports System.Globalization
Imports System.Diagnostics:Imports System.Web:
Imports System.IO:Imports System.Attribute
Imports System.CodeDom:Imports System.Net.WebClient
Imports System.Drawing:Imports Microsoft.VisualBasic
Imports Microsoft.Win32:Imports System.Net
Imports System.Object:Imports System.Xml
Imports System.Reflection:Imports System.Collections
Imports System.Runtime.InteropServices
Imports System.Windows:Imports System.Windows.Forms
Imports System.Threading:Imports System.CodeDom.Compiler
Imports System.Collections.Generic:Imports System.Text
Imports System.Runtime:Imports System.Drawing.Drawing2D
Imports System.Runtime.Serialization
Namespace Book4
''''''''''''''''''''''''''''''Style_Class''''''''''''''''''''''''''''
Public Class MyButton
Inherits Button
Public Sub New()
Me.TextAlign = ContentAlignment.MiddleCenter
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
Dim myEllipse As New System.Drawing.Rectangle(0, 0,Me.Width,Me.Height)
Dim myPath As New GraphicsPath
myPath.AddEllipse(myEllipse)
Me.Region = New Region(myPath)
For i As Integer =0 To -30 Step -3
Dim borderRectangle As Rectangle = Me.ClientRectangle
borderRectangle.Inflate(i,i)
ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, _
Border3DStyle.Raised)
Next
ControlPaint.DrawBorder(e.Graphics, ClientRectangle, _
Color.Blue,8, _
ButtonBorderStyle.Inset,Color.Blue, _
8,ButtonBorderStyle.Inset, _
Color.Blue,8, _
ButtonBorderStyle.Inset, Color.Blue, _
8, ButtonBorderStyle.Inset)
End Sub
End Class
''''''''''''''''''''''''''''''Style_Class''''''''''''''''''''''''''''
''Controls_Style
Public Class Styled_ComboBox1
Inherits System.Windows.Forms.Form
''-------------------------------------------------------------
''-------------------------------------------------------------
Public ComboBox1 As ComboBox
Public Button1 As Button
Public TextBox1 As TextBox
Public TextBox2 As TextBox
Public TextBox3 As TextBox
Public TextBox4 As TextBox
Public arr1 As String()
Public arr2 As String()
Public Sub New()
''-------------------------------------------------------------
''-------------------------------------------------------------
Me.SuspendLayout()
''-------------------------------------------------------------tbx1.Text
ComboBox1 = New ComboBox
ComboBox1.Size = New System.Drawing.Size(300,90)
ComboBox1.Location =New System.Drawing.Point(50,150)
ComboBox1.BackColor=System.Drawing.Color.Khaki
ComboBox1.ForeColor= System.Drawing.Color.Indigo
ComboBox1.DropDownWidth = 1300
ComboBox1.DropDownHeight = 800
ComboBox1.ItemHeight = 30
ComboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable
ComboBox1.Font = New System.Drawing.Font("Slab Serif",20.0!, _
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point, _
CType(0, Byte))
''-------------------------DataSource--------------------------
For i = 0 To arr1.Length -2
listB.AddRange(New String() {arr1(i) & arr1(i)})
ComboBox1.DataSource = listB
Threading.Thread.Sleep(0.1)
listB.AddRange(New String() {arr2(i) & arr2(i)})
ComboBox1.DataSource = listB
Next
listB.AddRange(New String() {strZ & strZ})
Me.Controls.Add(ComboBox1)
''-------------------------------------------------------------
AddHandler ComboBox1.DrawItem , New _
DrawItemEventHandler(AddressOf ComboBox1_DrawItem)
Button1 = New MyButton
Button1.Size = New System.Drawing.Size(200,120)
Button1.Location =New System.Drawing.Point(5,5)
Button1.BackColor=System.Drawing.Color.RoyalBlue
Button1.ForeColor= System.Drawing.Color.FloralWhite
Button1.Text = "Button1"
Button1.Font = New System.Drawing.Font("Algerian",15.0!, _
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point, _
CType(0, Byte))
TextBox1 = New TextBox
TextBox1.Size = New System.Drawing.Size(200,100)
TextBox1.Location =New System.Drawing.Point(300,5)
TextBox1.BackColor=System.Drawing.Color.Black
TextBox1.ForeColor= System.Drawing.Color.White
TextBox1.Text = "TextBox1"
TextBox1.Font = New System.Drawing.Font("Segoe UI",14.0!, _
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point, _
CType(0, Byte))
TextBox2 = New TextBox
TextBox2.Size = New System.Drawing.Size(200,100)
TextBox2.Location =New System.Drawing.Point(510,5)
TextBox2.BackColor=System.Drawing.Color.Black
TextBox2.ForeColor= System.Drawing.Color.White
TextBox2.Text = "TextBox2"
TextBox2.Font = New System.Drawing.Font("Segoe UI",14.0!, _
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point, _
CType(0, Byte))
TextBox3 = New TextBox
TextBox3.Size = New System.Drawing.Size(200,100)
TextBox3.Location =New System.Drawing.Point(720,5)
TextBox3.BackColor=System.Drawing.Color.Black
TextBox3.ForeColor= System.Drawing.Color.White
TextBox3.Text = "TextBox3"
TextBox3.Font = New System.Drawing.Font("Segoe UI",14.0!, _
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point, _
CType(0, Byte))
TextBox4 = New TextBox
TextBox4.Size = New System.Drawing.Size(200,100)
TextBox4.Location =New System.Drawing.Point(930,5)
TextBox4.BackColor=System.Drawing.Color.Black
TextBox4.ForeColor= System.Drawing.Color.White
TextBox4.Text = "TextBox4"
TextBox4.Font = New System.Drawing.Font("Segoe UI",14.0!, _
System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point, _
CType(0, Byte))
''Control_Property
''-------------------------------------------------------------
''Specific_Insert_Code
''-------------------------------------------------------------
Me.Controls.Add(ComboBox1)
Me.Controls.Add(Button1)
Me.Controls.Add(TextBox1)
Me.Controls.Add(TextBox2)
Me.Controls.Add(TextBox3)
Me.Controls.Add(TextBox4)
''Controls_Inclusion
''-------------------------------------------------------------
Me.ClientSize = New System.Drawing.Size(1920,1040)
Me.BackColor = ColorTranslator.FromHtml("#FF2F4F4F")
''Me.BackgroundImage = Image.FromFile("D:\DllMaster\BG\BG_Image12.jpg")
Me.Text ="Styled_ComboBox1"
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Name = "Styled_ComboBox1"
Me.AutoScroll = True
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
''Specific_Insert_Events
''-------------------------------------------------------------
Public Shared Sub Main()
Dim form1 As Styled_ComboBox1 = New Styled_ComboBox1()
form1.ShowDialog()
End Sub
Public Sub Styled_ComboBox1_Loaded(sender As Object, e As EventArgs) _
Handles MyBase.Load
Try
Try
Dim dtTest As DataTable = New DataTable()
dtTest.Columns.Add("ID", GetType(Integer))
dtTest.Columns.Add("Name", GetType(String))
dtTest.Columns.Add("Surname", GetType(String))
dtTest.Rows.Add(1, "John", "Wolf")
dtTest.Rows.Add(2, "Amy", "Blue")
dtTest.Rows.Add(3, "Tony", "Jhonson")
dtTest.Rows.Add(4, "Bruce", "Lee")
dtTest.Rows.Add(5, "Allen", "deWatt")
ComboBox1.DataSource = dtTest
ComboBox1.DisplayMember = "Name"
ComboBox1.ValueMember = "ID"
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
End Sub
Public Sub ComboBox1_DrawItem(ByVal sender As Object, ByVal e _
As System.Windows.Forms.DrawItemEventArgs)
Try
Try
e.DrawBackground()
Dim drv As DataRowView = CType(comboBox1.Items(e.Index), DataRowView)
Dim id As Integer = drv("ID").ToString()
Dim nume As String = drv("Name").ToString()
Dim prenume As String = drv("Surname").ToString()
Dim r1 As Rectangle = e.Bounds
r1.Height = r1.Width / 6
Using sb As SolidBrush = New SolidBrush(System.Drawing.Color.Brown) '''
e.Graphics.DrawString(id, e.Font, sb, r1)
End Using
Using p1 As Pen = New Pen(Color.Black)
e.Graphics.DrawLine(p1, r1.Right, 0, r1.Right, r1.Bottom)
End Using
Dim r2 As Rectangle = e.Bounds
r2.X = e.Bounds.Width / 1.5
r2.Width = r2.Width / 5
Using sb As SolidBrush = New SolidBrush(System.Drawing.Color.Green)
e.Graphics.DrawString(nume, e.Font, sb, r2)
End Using
Dim r3 As Rectangle = e.Bounds
r3.X = e.Bounds.Width / 6
r3.Width = r3.Width / 2
Using sb As SolidBrush = New SolidBrush(e.ForeColor)
e.Graphics.DrawString(prenume, e.Font, sb, r3)
End Using
Using p2 As Pen = New Pen(Color.Black)
e.Graphics.DrawLine(p2, r2.Left, 0, r2.Left, r2.Bottom)
End Using
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
End Sub
''-------------------------------------------------------------
Public Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Try
ComboBox1.SelectedIndex = 9
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
End Sub
''Event_Handlers
End Class
End Namespace