在vb.net 2010中绘制Rectanle [英] Draw Rectanle in vb.net 2010

查看:47
本文介绍了在vb.net 2010中绘制Rectanle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PLS ..

PLS ..

如何使用鼠标在窗体上绘制矩形..

解决方案

因为你提到在表单上我会假设这不是VB.NET - 这是基于broswer的 - 而是WinForms,它不是。



这并不太难:

1)处理表格中的MouseDown,MouseMove和MouseUp事件。同时处理Paint事件。

2)创建三个类级变量:一个名为 start 的Point,一个名为当前和一个叫做移动的布尔值。

3)在MouseDown处理程序中,设置移动 true 开始到当前鼠标位置。 />
4)在MouseUp事件中,将移动设置为 false

5)在MouseMove事件中,查看移动。如果 true ,将当前设置为当前鼠标位置,并调用 Invalidate 方法。

6) Invalidate 导致重新绘制表单,导致调用Paint事件处理程序。

7)在Paint处理程序中,使用PaintEventArgs参数Graphics属性,并调用它的DrawRectangle方法 - 它有一个需要两点的重载。



完成!


您好,我认为这些链接对您有用:

http://www.techotopia.com/index.php/ Drawing_Graphics_in_Visual_Basic http://social.msdn.microsoft.com/Forums/en-US/39d5e468-f76b-4d44-954b-d220eed57cf4/make-drawings-with-mouse-in-window-form-in-vbnet-2005-or -2010?论坛= Vsexpressvb

PLS..
PLS..
how to draw Rectangle using mouse on the form..

解决方案

Since you refer to "on the form" I will assume this is not VB.NET - which is broswer based - but WinForms, which isn't.

It's not too difficult:
1) Handle the MouseDown, MouseMove and MouseUp events for teh form. Also Handle the Paint event.
2) Create three class level variables: a Point called "start", a Point called "current" and a bool called "moving".
3) In the MouseDown handler, set moving to true and start to the current mouse position.
4) In the MouseUp event, set moving to false
5) In the MouseMove event, look at moving. If it is true, set current to the current mouse position, and call the Invalidate method.
6) Invalidate causes the form to be re-drawn, causing the Paint event handler to be called.
7) In the Paint handler, use the PaintEventArgs parameter Graphics property, and call it's DrawRectangle method - it has an overload that takes two points.

Done!


Hi, I think these link will be useful for you:
http://www.techotopia.com/index.php/Drawing_Graphics_in_Visual_Basic http://social.msdn.microsoft.com/Forums/en-US/39d5e468-f76b-4d44-954b-d220eed57cf4/make-drawings-with-mouse-in-window-form-in-vbnet-2005-or-2010?forum=Vsexpressvb


这篇关于在vb.net 2010中绘制Rectanle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆