重写Form的OnPaint方法. 把绘制代码贴到那里面去.ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfSystemWindowsFormsFormClassOnPaintTopic.htm
解决方案 »
- 列表框,组合框
- 关于子窗口向父窗口传值的问题
- VS2008(C#)中AJAX的使用问题
- ((DataView)CurrencyManager.List).AllowNew = false 反应非常慢 ?
- c#字符串问题
- 求源程序
- (菜鸟问题)在工具栏事件处理中如何调用菜单处理程序,请帮忙,来者有分
- 哪里(网站)有学习IE WEB CONTROLS(toolbar,tabstrip,multipage)的学习资料啊??
- 1.# define SPP 是什么意思 2.main函数是如何开始运行的
- 请问在c#中如何将一个字符转换成ascll码?(肯定给分)
- 如何调用其他页面文件中定义的类方法
- 本人的学习日记,请专家指导。
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);//这行必须要
//调用你的绘制方法
.....
.....}
能不能给各详细点的例子我的代码:
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Bitmap bmpWhite=new Bitmap(Application.StartupPath+@"\white1.gif");
Bitmap bmpBlack=new Bitmap(Application.StartupPath+@"\black1.gif");
Graphics g=this.CreateGraphics();
int x=e.X-40 ;
int y=e.Y-40 ;
int i, j , vi, vj;
i=x/26;
j=y/26;
vi=x%26;
vj=y%26;
if(vi>13) i++;
if(vj>13) j++;
this.Text=i.ToString() +j.ToString () ;
if( i>=0 && j>=0 && i<=14 && j<=14)
{
if(isblackturn==true)
{
g.DrawImage(bmpBlack,40+26*i-bmpBlack.Width/2 ,40+26*j-bmpBlack.Height/2 ,bmpBlack.Width,bmpBlack.Height);
isblackturn=!isblackturn;
}
else
{
g.DrawImage(bmpWhite,40+26*i-bmpWhite.Width/2 ,40+26*j-bmpWhite.Height/2 ,bmpWhite.Width,bmpWhite.Height);
isblackturn=!isblackturn;
}
}
}
g.DrawImage(bmpBlack,40+26*i-bmpBlack.Width/2 ,40+26*j-bmpBlack.Height/2 ,bmpBlack.Width,bmpBlack.Height);
isblackturn=!isblackturn;
这些写成一个方法或者类,然后根据一些全局变量(如isblackturn)在onPaint中调用