ListBox CodeSample - Populating with List of KeyValuePair objects
Categories: Selection, Built-in
|
Tags: Developers, Data Binding, 1. Beginner, Data Binding, Pre v6.3, v6.3, v6.4 and Later, 2. Intermediate, 3. Advanced
Revision:
1
Posted:
04/Oct/2009
Updated:
23/July/2010
Status:
Publish
Types: Code
|
This article will have a few sections added to it soon, based on the following article type skeleton: CodeSample OverviewThis codesample demonstrates how you can populate ListBox by creating a List of KeyValuePair objects and assigning to the DataSource. VB.NET Code
Imports Gizmox.WebGui.Forms
Public Class KVPListBox
Inherits ListBox
Private uList As List(Of KeyValuePair(Of String, String)) = New List(Of KeyValuePair(Of String, String))
Sub New()
MyBase.New()
End Sub
Friend Sub ReloadData()
uList.Add(New KeyValuePair(Of String, String)("001", "Tommy twodime"))
uList.Add(New KeyValuePair(Of String, String)("002", "Jhonny boy"))
uList.Add(New KeyValuePair(Of String, String)("003", "John Doe"))
uList.Add(New KeyValuePair(Of String, String)("004", "Homer Simpson"))
uList.Add(New KeyValuePair(Of String, String)("005", "Superman"))
uList.Sort(AddressOf CompareKVP)
Me.DataSource = uList
Me.ValueMember = "Key"
Me.DisplayMember = "Value"
End Sub
Private Shared Function CompareKVP( _
ByVal x As KeyValuePair(Of String, String), ByVal y As KeyValuePair(Of String, String)) As Integer
Return x.Value.CompareTo(y.Value)
End Function
End Class
' In your form, after instanciating an object of type KVPListBox, in this example you will have to call:
KvpListBox1.ReloadData()
C# CodeThe conversion of this code to C# has not been completed yet.
About the author
Related Articles
|
Selection
|
|
|
Tags:
Developers, Data Binding, Navigation, 1. Beginner, 2. Intermediate, Data Binding, Navigation, ASP.NET, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
Control of a combobox with a checked list and a tree.
Tags:
Developers, Navigation, 2. Intermediate, 3. Advanced, Customization, Layouting, Navigation, Pre v6.3, v6.3, v6.4 and Later
|
|
|
This code demonstrates the usage of the different AutoCompleteMode values property of ComboBox control
Tags:
Developers, Data Binding, Navigation, 1. Beginner, 2. Intermediate, 3. Advanced, Navigation, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Developers, Data Binding, Windows & Dialogs, 1. Beginner, 2. Intermediate, Customization, Data Binding, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
Tags:
Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Developers, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
|