Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is code I have used to fill two list boxes with all system colours and theme colours. Perhaps you could adapt for use in a combo box?</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Reflection; /// &lt;summary&gt; /// loads the colours /// &lt;/summary&gt; private void LoadColours() { try { Color testColor = ProfessionalColors.ButtonCheckedGradientBegin; Type colorType = testColor.GetType(); PropertyInfo[] propInfoList = colorType.GetProperties( BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public ); lvColours.Items.Clear(); foreach ( PropertyInfo oPropertyInfo in propInfoList ) { Color color = ( Color ) oPropertyInfo.GetValue( null, null ); ListViewItem oListViewItem = new ListViewItem( GetColorName( oPropertyInfo.Name ) ); oListViewItem.BackColor = color; lvColours.Items.Add( oListViewItem ); } Type ProfType = typeof( ProfessionalColors ); PropertyInfo[] PropInfos = ProfType.GetProperties( BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public ); foreach ( PropertyInfo oPropertyInfo in PropInfos ) { Color oColor =(Color) oPropertyInfo.GetValue( null, null ); ListViewItem oListViewItem = new ListViewItem( GetColorName( oPropertyInfo.Name ) ); oListViewItem.BackColor = oColor; lvProfessionalColours.Items.Add( oListViewItem ); } } catch ( Exception ex ) { MessageBox.Show( ex.Message ); } } /// &lt;summary&gt; /// Gets the Color Name /// &lt;/summary&gt; protected string GetColorName( string strFullName ) { string strName = ""; int idx = strFullName.LastIndexOf( "." ); if ( idx != -1 ) { strName = strFullName.Substring( idx ); } else { return strFullName; } return strName; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload