GDI+重绘示例-boost电路计算模版——mathcad

时间:2024-06-29 17:46:28
【文件属性】:

文件名称:GDI+重绘示例-boost电路计算模版——mathcad

文件大小:5.1MB

文件格式:PDF

更新时间:2024-06-29 17:46:28

控件,.NET

51 第三章 GDI+基础 } private void Form2_Load(object sender, EventArgs e) { string[] _colorNames; _colorNames = System.Enum.GetNames(typeof(KnownColor)); cbbColors.Items.AddRange(_colorNames); cbbColors.SelectedIndex = 0; } protected override void OnPaint(PaintEventArgs e) { Pen drawingPen = new Pen(_color, 3); Rectangle rec = new Rectangle(80, 80, 120, 80); e.Graphics.DrawRectangle(drawingPen, rec); Brush brush=new SolidBrush(_color); e.Graphics.FillRectangle(brush,rec); drawingPen.Dispose(); base.OnPaint(e); } private Color _color = Color.Red; private void cbbColors_SelectedIndexChanged(object sender, EventArgs e) { KnownColor selectedColor; selectedColor = (KnownColor)System.Enum.Parse( typeof(KnownColor), cbbColors.Text); _color=System.Drawing.Color.FromKnownColor( selectedColor); //重绘 this.Invalidate(); } } } 运行该窗体,结果如图3.3所示。 图3.3 GDI+重绘示例


网友评论