Vs2005窗体设计如何执行Form4_Paint?

[复制链接]
查看11 | 回复1 | 2008-10-25 19:25:14 | 显示全部楼层 |阅读模式
namespace winapp
{

public partial class Form4 : Form

{

public Form4()

{

InitializeComponent();

}

private void Form4_Paint(object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics g = e.Graphics;

g.DrawString("circle 99", this.Font, new SolidBrush(Color.Blue), 20, 20);

int x0 = this.Width / 2;

int y0 = this.Height / 2;

for (int r = 0; r < this.Height / 2; r += 3)

{

g.DrawEllipse(new Pen(getRandomColor(), 1), x0 - r, y0 - r, r * 2, r * 2);

}

}

private Color getRandomColor()

{

Random rnd = new Random();

return Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));

}

}
}

回复

使用道具 举报

千问 | 2008-10-25 19:25:14 | 显示全部楼层
在Form4.Designer.cs文件中 private void InitializeComponent()
{......this.Form.Paint += new System.Windows.Forms.PaintEventHandler(this.Form4_Paint);......}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行