首页 新闻 会员 周边

c# gdi画图 一个小测试而已为什么没有显示呢

0
悬赏园豆:5 [待解决问题]
public Form1()
{
InitializeComponent();
int x = this.Location.X+10;
int y = this.Location.Y+10;
int height = this.Size.Height, width = this.Size.Width;
Bitmap bm = new Bitmap(height, width);
Graphics g = Graphics.FromImage(bm);

g.Clear(Color.White);
Pen p = new Pen(Color.Black, 1);
// LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, bm.Width, bm.Height),Color.Blue, Color.BlueViolet, 1.2f, true);

g.FillRectangle(Brushes.White, x, y, width, height);
g.DrawRectangle(new Pen(Color.Blue), 0, 0, bm.Width - 1, bm.Height - 1);
g.DrawLine(p, x, y, x, y + 140);
g.DrawLine(p, x, y, x + 140, y);
}
希格绍尔的主页 希格绍尔 | 初学一级 | 园豆:190
提问于:2012-01-31 09:44
< >
分享
所有回答(2)
0

你的g.FillRectangle(Brushes.White, x, y, width, height);颜色有关吧。改一个颜色试试。

悟行 | 园豆:12559 (专家六级) | 2012-01-31 15:06
0

把画的代码 放在 onPaint()函数里试试!

james.dong | 园豆:91 (初学一级) | 2012-01-31 15:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册