Click here to Skip to main content
15,892,746 members
Articles / Programming Languages / Visual Basic

Flatten that Combobox!

Rate me:
Please Sign up or sign in to vote.
4.24/5 (19 votes)
2 Feb 20035 min read 276.7K   3.5K   25  
A flat style combobox in VB.NET
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog
    Friend WithEvents ComboBox1 As FlatCombo
    Friend WithEvents FlatCombo1 As FlatCombo
    Friend WithEvents FlatCombo2 As FlatCombo
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.MainMenu1 = New System.Windows.Forms.MainMenu()
        Me.ColorDialog1 = New System.Windows.Forms.ColorDialog()
        Me.ComboBox1 = New FlatCombobox2.FlatCombo()
        Me.FlatCombo1 = New FlatCombobox2.FlatCombo()
        Me.FlatCombo2 = New FlatCombobox2.FlatCombo()
        Me.SuspendLayout()
        '
        'ComboBox1
        '
        Me.ComboBox1.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(192, Byte))
        Me.ComboBox1.ButtonColor = System.Drawing.Color.Firebrick
        Me.ComboBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ComboBox1.Items.AddRange(New Object() {"1", "2", "3", "4", "5", "6", "7", "8", "9"})
        Me.ComboBox1.Location = New System.Drawing.Point(8, 8)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(176, 21)
        Me.ComboBox1.TabIndex = 4
        Me.ComboBox1.Text = "Get Colorfull"
        '
        'FlatCombo1
        '
        Me.FlatCombo1.BackColor = System.Drawing.Color.Brown
        Me.FlatCombo1.ButtonColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(128, Byte), CType(0, Byte))
        Me.FlatCombo1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FlatCombo1.ForeColor = System.Drawing.Color.White
        Me.FlatCombo1.Items.AddRange(New Object() {"1", "2", "3", "4", "5", "6", "7", "8", "9"})
        Me.FlatCombo1.Location = New System.Drawing.Point(8, 40)
        Me.FlatCombo1.Name = "FlatCombo1"
        Me.FlatCombo1.Size = New System.Drawing.Size(176, 21)
        Me.FlatCombo1.TabIndex = 5
        Me.FlatCombo1.Text = "If you want to"
        '
        'FlatCombo2
        '
        Me.FlatCombo2.ButtonColor = System.Drawing.SystemColors.Control
        Me.FlatCombo2.Items.AddRange(New Object() {"Or just accept", "the default system", "colors for the control"})
        Me.FlatCombo2.Location = New System.Drawing.Point(8, 72)
        Me.FlatCombo2.Name = "FlatCombo2"
        Me.FlatCombo2.Size = New System.Drawing.Size(176, 21)
        Me.FlatCombo2.TabIndex = 6
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(192, 141)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.FlatCombo2, Me.FlatCombo1, Me.ComboBox1})
        Me.Menu = Me.MainMenu1
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Malaysia Malaysia
As an experienced programmer, I know how hard it is to find good code sometimes. I hope my articles and samples are as good for you as they are for me. Need more good code? Email me.

Comments and Discussions