通过重写C#中的ComboBox类
源代码在线查看: form1.designer.cs
namespace CustomColoredComboBox
{
partial class Form1
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.coloredComboBox1 = new CustomColoredComboBox.ColoredComboBox();
this.SuspendLayout();
//
// coloredComboBox1
//
this.coloredComboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.coloredComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.coloredComboBox1.FormattingEnabled = true;
this.coloredComboBox1.Items.AddRange(new object[] {
"Black",
"Red",
"Blue",
"Green",
"Pink",
"DarkRed",
"Yellow",
"Orange"});
this.coloredComboBox1.Location = new System.Drawing.Point(12, 12);
this.coloredComboBox1.MyColors = new string[] {
"Black",
"Red",
"Blue",
"Green",
"Pink",
"DarkRed",
"Yellow",
"Orange",
"x"};
this.coloredComboBox1.Name = "coloredComboBox1";
this.coloredComboBox1.Size = new System.Drawing.Size(103, 21);
this.coloredComboBox1.TabIndex = 0;
this.coloredComboBox1.SelectedIndexChanged += new System.EventHandler(this.coloredComboBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(242, 173);
this.Controls.Add(this.coloredComboBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private ColoredComboBox coloredComboBox1;
}
}