Enum Binding : ListBox « GUI « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » GUI » ListBoxScreenshots 
Enum Binding
  

Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.ListBox1 = New System.Windows.Forms.ListBox()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        Me.Button1.Location = New System.Drawing.Point(10424)
        Me.Button1.Size = New System.Drawing.Size(18424)
        Me.Button1.Text = "Bind to Enum"
        '
        Me.ListBox1.Location = New System.Drawing.Point(104112)
        Me.ListBox1.Size = New System.Drawing.Size(18482)
        '
        Me.Button2.Location = New System.Drawing.Point(10464)
        Me.Button2.Size = New System.Drawing.Size(18424)
        Me.Button2.Text = "Display Value of Selected"
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(392246)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.ListBox1, Me.Button1})
        Me.ResumeLayout(False)
    End Sub
    Public Enum Test
        A = 1
        B = 2
        C = 3
    End Enum

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button1.Click
        ListBox1.DataSource = System.Enum.GetNames(GetType(Test))
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button2.Click
        Dim strNames As Array = System.Enum.GetValues(GetType(Test))
        Dim strValue As String = strNames(ListBox1.SelectedIndex)
        MessageBox.Show(strValue)
    End Sub
End Class

   
    
  
Related examples in the same category
1.Toggling list box Selection Mode: select one or select more than oneToggling list box Selection Mode: select one or select more than one
2.Draw selected Item in ListBoxDraw selected Item in ListBox
3.Owner Draw ListBoxOwner Draw ListBox
4.Add Item to ListBoxAdd Item to ListBox
5.Add Item to a List Box by clicking a ButtonAdd Item to a List Box by clicking a Button
6.Get Selected Item from ListBoxGet Selected Item from ListBox
7.Add, remove and clear list box itemsAdd, remove and clear list box items
8.List Box and Spinner DemoList Box and Spinner Demo
9.Customize ListBox Font and Item HeightCustomize ListBox Font and Item Height
10.Drag and drop between two ListBoxDrag and drop between two ListBox
11.Set ListBox TopIndexSet ListBox TopIndex
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.