• 大小: 87KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-16
  • 语言: C#
  • 标签: c#  自定义  控件  ComboBox  

资源简介

C# 自定义控件 自定义ComboBox。其他控件的自定义与此类似。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace BeautifyComboBox
{
    public partial class B_ComboBox : ComboBox
    {
        public B_ComboBox()
        {
            InitializeComponent();
            this.DrawMode = DrawMode.OwnerDrawFixed;
            //this.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ListBox_DrawItem);
        }

        #region 变量
        private static Brush[] listBoxBrushes;//该数组用来存储绘制listBox1背景的Brush对象
        private static int place = -1;//颜色位置的取值
        private static bool naught = true;//判断是否重绘
        #endregion

        #region 属性

        private bool TGradualC = false;
        [Browsable(true) Category(“控件的重绘设置“) Description(“判断是否进行渐变色的设置“)] //在“属性”窗口中显示Datastyle属性
        public bool GradualC
        {
            get { return TGradualC; }
            set
            {
                TGradualC = value;
                this.Invalidate();
            }
        }

        private Color TColorSelect = Color.Gainsboro;
        [Browsable(true) Category(“控件的重绘设置“) Description(“项被选中后的高亮度颜色“)] //在“属性”窗口中显示Datastyle属性
        public Color ColorSelect
        {
            get { return TColorSelect; }
            set
            {
                TColorSelect = value;
                this.Invalidate();
            }
        }

        private Color TColor1 = Color.CornflowerBlue;
        [Browsable(true) Category(“控件的重绘设置“) Description(“第一个颜色的设置“)] //在“属性”窗口中显示Datastyle属性
        public Color Color1
        {
            get { return TColor1; }
            set
            {
                TColor1 = value;
                this.Invalidate();
            }
        }

        private Color TColor1Gradual = Color.Thistle;
        [Browsable(true) Category(“控件的重绘设置“) Description(“第一个颜色的渐变色设置“)] //在“属性”窗口中显示Datastyle属性
        public Color Color1Gradual
        {
            get { return TColor1Gradual; }
            set
            {
                TColor1Gradual = value;
                this.Invalidate();
            }
        }

        private Color TColor2 = Color.PaleGreen;
        [Browsable(true) Category(“控件的重绘设置“) Description(“第二个颜色的设置“)] //在“属性”窗口中显示Datastyle属性
        public Color Color2
        {
            get { return TColor2; }
            set
            {
                TColor2 = value;
                this.Invalidate();
            }
        }

        private Color TColor2Gradual = Color.DarkKhaki;
        [Browsable(true) Category(“控件的重绘设置“) Description(“第二个颜色的渐变色设置“)] //在“属性”窗口中显示Datastyle属性
        public Color Color2Gradual
        {
            get { return TColor2Gradual; }
            set
            {
                TColor2Gradual = value;
                this.Invalidate();
            }
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-24 10:24  美化ComboBox\
     目录           0  2018-08-24 10:23  美化ComboBox\.vs\
     目录           0  2018-08-24 10:23  美化ComboBox\.vs\BeautifyComboBox\
     目录           0  2018-08-24 10:23  美化ComboBox\.vs\BeautifyComboBox\v14\
     文件       30720  2018-08-24 10:24  美化ComboBox\.vs\BeautifyComboBox\v14\.suo
     目录           0  2018-08-24 10:24  美化ComboBox\Backup\
     目录           0  2018-08-24 10:24  美化ComboBox\Backup\BeautifyComboBox\
     文件        1225  2009-02-12 14:48  美化ComboBox\Backup\BeautifyComboBox\B_ComboBox.Designer.cs
     文件        5789  2009-02-12 14:49  美化ComboBox\Backup\BeautifyComboBox\B_ComboBox.cs
     文件        5995  2009-02-12 14:48  美化ComboBox\Backup\BeautifyComboBox\B_ComboBox.resx
     文件        4112  2009-02-12 14:50  美化ComboBox\Backup\BeautifyComboBox\BeautifyComboBox.csproj
     文件        2641  2009-02-12 14:50  美化ComboBox\Backup\BeautifyComboBox\Form1.Designer.cs
     文件         366  2009-02-12 14:50  美化ComboBox\Backup\BeautifyComboBox\Form1.cs
     文件        5814  2009-02-12 14:50  美化ComboBox\Backup\BeautifyComboBox\Form1.resx
     文件         497  2009-02-12 14:47  美化ComboBox\Backup\BeautifyComboBox\Program.cs
     目录           0  2018-08-24 10:24  美化ComboBox\Backup\BeautifyComboBox\Properties\
     文件        1364  2009-02-12 14:47  美化ComboBox\Backup\BeautifyComboBox\Properties\AssemblyInfo.cs
     文件        2882  2009-02-12 14:47  美化ComboBox\Backup\BeautifyComboBox\Properties\Resources.Designer.cs
     文件        5612  2009-02-12 14:47  美化ComboBox\Backup\BeautifyComboBox\Properties\Resources.resx
     文件        1101  2010-08-18 17:50  美化ComboBox\Backup\BeautifyComboBox\Properties\Settings.Designer.cs
     文件         249  2009-02-12 14:47  美化ComboBox\Backup\BeautifyComboBox\Properties\Settings.settings
     文件         938  2009-02-12 14:47  美化ComboBox\Backup\BeautifyComboBox.sln
     目录           0  2018-08-24 09:53  美化ComboBox\BeautifyComboBox\
     文件        1225  2009-02-12 14:48  美化ComboBox\BeautifyComboBox\B_ComboBox.Designer.cs
     文件        5789  2009-02-12 14:49  美化ComboBox\BeautifyComboBox\B_ComboBox.cs
     文件        5995  2009-02-12 14:48  美化ComboBox\BeautifyComboBox\B_ComboBox.resx
     文件        4302  2018-08-24 10:24  美化ComboBox\BeautifyComboBox\BeautifyComboBox.csproj
     文件        2641  2009-02-12 14:50  美化ComboBox\BeautifyComboBox\Form1.Designer.cs
     文件         366  2009-02-12 14:50  美化ComboBox\BeautifyComboBox\Form1.cs
     文件        5814  2009-02-12 14:50  美化ComboBox\BeautifyComboBox\Form1.resx
     文件         497  2009-02-12 14:47  美化ComboBox\BeautifyComboBox\Program.cs
............此处省略29个文件信息

评论

共有 条评论