Paint事件

dmhorse 2003-07-19 10:54:37
using System;
using System.Windows.Forms;
using System.Threading;
using System.Drawing;

namespace myproject
{

class ConsoleHelloWorld
{
static int j = 0;
public static void Main()
{
Form form = new System.Windows.Forms.Form();
// form.Show();
// Thread.Sleep(2000);
form.Text = "my form";
// Thread.Sleep(3000);
form.Paint += new PaintEventHandler(MyPaintHandler);
Application.Run(form);


/*
string str = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
Date mydate = new Date();
//string str = "abC";
mydate.Year = 10;
System.Console.WriteLine(mydate.Year);
System.Console.WriteLine("hello world");
DialogResult dr = System.Windows.Forms.MessageBox.Show("hello");
System.Console.WriteLine(dr);
System.Console.WriteLine(str);
*/

}//End main method

static void MyPaintHandler(object sender,PaintEventArgs pea)
{
Form form = (Form)sender;
Graphics grfx = pea.Graphics;
grfx.Clear(Color.Chocolate);
j++;
grfx.DrawString("Paint Event" + j ,form.Font,Brushes.Black,0,j);

}



}



class Date
{
int year;
public int Year
{
set
{
year = value;
}
get
{
return year;
}
}
}
}

grfx.DrawString("Paint Event" + j ,form.Font,Brushes.Black,0,j);
为什么这行打出来的字符位置老是相同?是否win form响应不过来?
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fishsward 2003-07-20
  • 打赏
  • 举报
回复
应该不会吧!
panyee 2003-07-19
  • 打赏
  • 举报
回复
是不是就只执行了一次?

在MyPaintHandler设个断点跟踪一下

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧