ColorComboBox CodeSample - Populating with SystemColors
From Visual WebGui Wiki
| This article will have a few sections added to it soon, based on the following article type skeleton: NewCodeSampleTemplate |
Overview
This 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# Code
| This part of the article has not been completed yet. Please feel free to contribute and add contents to the Wiki |
