ColorComboBox CodeSample - Populating with SystemColors
Categories: Selection
|
Tags: Developers, Data Binding, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
Revision:
1
Posted:
20/Sep/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 sample is taken from the Catalog sample application, and you can find the GetConstraints() function within RandomData.cs, and the population by using DataSource within the folder
Categories\Behaviours\ListDataBindingBehaviour.cs The sample uses SystemColors class and Reflection to build a list of colors to show in the ColorComboBox. VB.NET code
Private Sub PopulateCombo()
ColorComboBox2.DisplayMember = "Name"
ColorComboBox2.ValueMember = "Name"
ColorComboBox2.DataSource = GetConstants(GetType(SystemColors))
End Sub
Private Function GetConstants(ByVal enumType As Type) As Color()
Dim attributes1 As MethodAttributes = MethodAttributes.[Static] Or MethodAttributes.[Public]
Dim infoArray1 As PropertyInfo() = enumType.GetProperties()
Dim list1 As New ArrayList()
For num1 As Integer = 0 To infoArray1.Length - 1
Dim info1 As PropertyInfo = infoArray1(num1)
If info1.PropertyType Is GetType(Color) Then
Dim info2 As MethodInfo = info1.GetGetMethod()
If (info2 IsNot Nothing) AndAlso ((info2.Attributes And attributes1) = attributes1) Then
Dim objArray1 As Object() = Nothing
list1.Add(info1.GetValue(Nothing, objArray1))
End If
End If
Next
Return DirectCast(list1.ToArray(GetType(Color)), Color())
End Function
C# CodeThis part of the article 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
|
|
|
|