Search KB Filter article types
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
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.

About the author

Related Articles

Selection  
Title Update Author
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
11/Jan/2009    2009/01/11
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
06/Jan/2008    2008/01/06
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
12/Jan/2007    2007/01/12
Tags: Developers, Data Binding, Windows & Dialogs, 1. Beginner, 2. Intermediate, Customization, Data Binding, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
03/Jan/2009    2009/01/03
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
04/Dec/2010    2010/12/04
Tags: Developers, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
21/July/2010    2010/07/21
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS