如何在csharp Windows应用程序中使用鼠标画线 [英] How to Draw line using mouse in csharp windows application

查看:89
本文介绍了如何在csharp Windows应用程序中使用鼠标画线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很高兴
我想做一个简单的基于窗口的软件
用鼠标画一条线
就像在ms字中画一条线一样
请帮助我...

hi i am sudheer
i want to do a simple window based software
to draw a line using mouse
it''s as same like draw a line in ms word
please help me ...

推荐答案

这真的很容易.处理鼠标事件,鼠标向下,向上和移动.调用Invalidate()以使窗体重新绘制自身,并使用Paint事件在作为起点存储的点与鼠标所在的位置之间绘制一条线.将线条添加到结构体集合中,以便您的绘画事件可以绘制要永久保留的线条.
This is really easy. Handle your mouse events, mouse down, up and move. Call Invalidate() to make your form redraw itself and use your Paint event to draw a line between the point that you stored as a starting point, and where the mouse is. Add the line to a collection of structs so your paint event can draw the lines you want to make permanent.


这篇关于如何在csharp Windows应用程序中使用鼠标画线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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