SoFunction
Updated on 2025-03-06

c# construct ColorComboBox (color drop-down box)


    class ColorComboBox : ComboBox
    {
        /// <summary>
/// The color is currently selected
        /// </summary>
        public Color SelectedColor
        {
            get { return (); }
        }
        /// <summary>
/// Constructor, construct color drop-down list
        /// </summary>
        public ColorComboBox()
        {
            = ;
            = ;
            = 25;

            PropertyInfo[] propInfoList = typeof(Color).GetProperties( | | );
            foreach (PropertyInfo c in propInfoList)
            {
                ();
            }
= "Black"; //Set the default color
        }

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Rectangle rect = ;

            if ( >= 0)
            {
                string colorName = [].ToString();
                Color c = (colorName);
using (Brush b = new SolidBrush(c)) //Reserve the pull-down interval
                {
                    (b, , + 2, , - 4);
                }
            }
        }