如何根据button事件引起paint事件 在Paint 事件中画矩形在button_clicked 中调用Invalidate(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 感谢您使用微软产品。您可以通过Form对象的CreateGraphics()方法来获得其Graphics对象。然后,通过Graphics对象的DrawRectangle方法来绘制矩形。下面提供一段示例程序,供您参考:using System.Drawing;using System.Drawing.Drawing2D;…… private void button1_Click(object sender, System.EventArgs e) { Graphics g = this.CreateGraphics(); // Create pen. Pen bluePen = new Pen(Color.Blue, 3); // Create location and size of rectangle. float x = 10.0F; float y = 10.0F; float width = 200.0F; float height = 200.0F; // Draw rectangle to screen. g.DrawRectangle(bluePen, x, y, width, height); g.Dispose(); }关于CreateGraphics方法的更详细信息,请参考微软MSDN:ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWindowsFormsControlClassCreateGraphicsTopic.htm— 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。 在button- licked中调用paint事件函数,参数用null,null代替,我没试过不知道行不行 求16进制形式字符串无变化转换成byte数组 [C#]简单的问题,关于ArrayList 请教下什么是句柄 Application.StartupPath 问题 请问怎么把这个代码做成一个方法? webform中如何转换http://localhost/dssweb/web/dti/configure为物理路径? Visual C#.NET程序员 读取Excel的方法好象有点问题 解决这个棘手的问题,感激万分 用C#如何达到当关闭应用程序(窗体)时,弹出MessageBox,然后按取消按钮可以不关闭窗体,回到应用程序 c# .net继承的窗体不能修改服类定义的控件的值,怎么办呀?
下面提供一段示例程序,供您参考:using System.Drawing;
using System.Drawing.Drawing2D;
……
private void button1_Click(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
// Create pen.
Pen bluePen = new Pen(Color.Blue, 3);
// Create location and size of rectangle.
float x = 10.0F;
float y = 10.0F;
float width = 200.0F;
float height = 200.0F;
// Draw rectangle to screen.
g.DrawRectangle(bluePen, x, y, width, height);
g.Dispose();
}关于CreateGraphics方法的更详细信息,请参考微软MSDN:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWindowsFormsControlClassCreateGraphicsTopic.htm— 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
不知道行不行