最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

c#構(gòu)造ColorComboBox(顏色下拉框)

 更新時間:2013年12月09日 11:18:02   作者:  
這篇文章主要介紹了c#構(gòu)造ColorComboBox的代碼分享,大家參考使用吧

復(fù)制代碼 代碼如下:

    class ColorComboBox : ComboBox
    {
        /// <summary>
        /// 當(dāng)前選中色
        /// </summary>
        public Color SelectedColor
        {
            get { return Color.FromName(this.Text); }
        }
        /// <summary>
        /// 構(gòu)造函數(shù),構(gòu)造顏色下拉列表
        /// </summary>
        public ColorComboBox()
        {
            this.DrawMode = DrawMode.OwnerDrawFixed;
            this.DropDownStyle = ComboBoxStyle.DropDownList;
            this.ItemHeight = 25;

            PropertyInfo[] propInfoList = typeof(Color).GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (PropertyInfo c in propInfoList)
            {
                this.Items.Add(c.Name);
            }
            this.Text = "Black"; //設(shè)置默認(rèn)色
        }

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

            if (e.Index >= 0)
            {
                string colorName = this.Items[e.Index].ToString();
                Color c = Color.FromName(colorName);
                using (Brush b = new SolidBrush(c)) //預(yù)留下拉項間距
                {
                    e.Graphics.FillRectangle(b, rect.X, rect.Y + 2, rect.Width, rect.Height - 4);
                }
            }
        }

相關(guān)文章

最新評論

永善县| 鄂温| 彝良县| 内乡县| 光山县| 兰溪市| 美姑县| 延寿县| 榆林市| 渭南市| 高阳县| 宝应县| 日照市| 巴中市| 聂拉木县| 鲁甸县| 合阳县| 日照市| 新昌县| 大同市| 河曲县| 平湖市| 三门县| 赣榆县| 平顺县| 舟曲县| 镇安县| 毕节市| 大荔县| 响水县| 邛崃市| 台安县| 泸水县| 曲沃县| 高州市| 任丘市| 开远市| 泾阳县| 衢州市| 嘉善县| 普陀区|