最新国产好看的视频,伊人天堂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ù)留下拉項(xiàng)間距
                {
                    e.Graphics.FillRectangle(b, rect.X, rect.Y + 2, rect.Width, rect.Height - 4);
                }
            }
        }

相關(guān)文章

最新評論

屏山县| 莱阳市| 宽甸| 阿拉善盟| 霸州市| 武宣县| 开原市| 陵川县| 永丰县| 阆中市| 东安县| 九台市| 新密市| 蕉岭县| 新民市| 河源市| 若尔盖县| 汤阴县| 闵行区| 类乌齐县| 黄浦区| 大田县| 沙洋县| 镇巴县| 工布江达县| 米泉市| 开鲁县| 昌宁县| 东城区| 翁牛特旗| 资兴市| 陆丰市| 溧水县| 临城县| 保定市| 邵东县| 巩义市| 湟源县| 卓尼县| 怀集县| 曲松县|