其实就是baidu一些常用的
代码如下
private void Form1_Load(object sender, System.EventArgs e)
{
// this.comboBox1.DisplayMember="Color";
this.comboBox1.Items.Add(Brushes.Cyan);
this.comboBox1.Items.Add(Brushes.DarkSalmon);
this.comboBox1.Items.Add(Brushes.Gray);
this.comboBox1.Items.Add(Brushes.Green);
this.comboBox1.Items.Add(Brushes.AliceBlue);
this.comboBox1.Items.Add(Brushes.Black);
this.comboBox1.Items.Add(Brushes.Blue);
this.comboBox1.Items.Add(Brushes.Chocolate);
this.comboBox1.Items.Add(Brushes.Pink);
this.comboBox1.Items.Add(Brushes.Red);
this.comboBox1.Items.Add(Brushes.LightBlue);
this.comboBox1.Items.Add(Brushes.Brown);
this.comboBox1.Items.Add(Brushes.DodgerBlue);
this.comboBox1.Items.Add(Brushes.MediumPurple);
this.comboBox1.Items.Add(Color.White);
this.comboBox1.Items.Add(Brushes.Yellow);
}
private void comboBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e)
{//ノ靹テチミア榘錞・
e.ItemHeight=this.comboBox1.ItemHeight-2;
}
private void comboBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{//サ贍ニチミア榘・
ComboBox MyCombox=(ComboBox)sender;
if(e.Index==-1)
return;
if(sender==null)
return;
SolidBrush MyBrush=(SolidBrush)MyCombox.Items[e.Index];
Graphics g=e.Graphics;
//ネ郢鋐ムセュス ミム。ヤ ャヤ 贍ニユネキオトアウセームユノォコヘセロシッソ・
e.DrawBackground();
e.DrawFocusRectangle();
//サ贍ニムユノォオトヤ、タタソ・
Rectangle MyRect=e.Bounds;
MyRect.Offset(2,2);
MyRect.Width=50;
MyRect.Height-=4;
g.DrawRectangle(new Pen(e.ForeColor),MyRect);
//サ 。ム。カィムユノォオトマ獗ヲサュヒ「カヤマ ャイ「フ鋧蕚、タタソ・
MyRect.Offset(1,1);
MyRect.Width-=2;
MyRect.Height-=2;
g.FillRectangle(MyBrush,MyRect);
//サ贍ニム。カィムユノォオトテ﨤ニ
g.DrawString(MyBrush.Color.Name.ToString(),Font,new SolidBrush(e.ForeColor),e.Bounds.X+60,e.Bounds.Y+1);
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{//マヤハセム。ヤ トムユノォ
if(this.comboBox1.SelectedIndex>=0)
{
SolidBrush MyBrush=(SolidBrush)(this.comboBox1.SelectedItem);
this.panel1.BackColor=MyBrush.Color;
}
}
}
Brushes类
所有标准颜色的画笔
DrawItemEventArgs 成员
公共构造函数
公共属性
公共方法
受保护的方法