如何使用鼠标在C#中绘制矩形 [英] How to draw a rectangle in C# using a mouse

查看:123
本文介绍了如何使用鼠标在C#中绘制矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#中的表单上绘制一个矩形.我阅读并发现了此文章.有样本或教程可用吗?这篇文章不是很有帮助.

解决方案

您链接的文章似乎是C ++,这也许可以解释为什么它对您没有太大帮助.

如果为MouseDown和MouseUp创建事件,则应具有矩形所需的两个角点.从那里开始,只需绘制表格即可.System.Drawing.*应该是您的第一站.以下链接了一些教程:

在WinForms中使用C#绘制图形

使用Winforms(StackOverflow)绘制矩形

使用C#进行图形编程

I want to draw a rectangle on a form in C#. I read and found this article. Are there any samples or tutorials available ? The article was not very helpful.

解决方案

The article you linked appears to be C++, which may explain why it didn't help you much.

If you create events for MouseDown and MouseUp, you should have the two corner points you need for a rectangle. From there, it's a matter of drawing on the form. System.Drawing.* should probably be your first stop. There are a couple of tutorials linked below:

Drawing with Graphics in WinForms using C#

Draw a rectangle using Winforms (StackOverflow)

Graphics Programming using C#

这篇关于如何使用鼠标在C#中绘制矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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