C#绘制不同的数字 [英] c# drawing diferent figures

查看:86
本文介绍了C#绘制不同的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以帮助我使用c#中的图形.这不是给我的,而是给我的朋友的.其实是功课

ex 示例
当我单击按钮绘制矩形时,然后单击另一个按钮绘制椭圆等

谢谢.

问候
h7h7!

Can Help me with graphics in c#. It isn''t for me, it is for my friend. In fact it is homework

ex example
when I click to button draw rectangle then when I click another button draw ellipse etc

Thanks.

regards
h7h7 !

推荐答案

你好

当然,我可以帮助您完成家庭作业,但正如我所说的"我可以帮助您",您可以不进行家庭作业.

如果是在WinForm中表示:

1.在后面的代码中创建2个方法
Hello

Of couse I help you to do your homework but as i said "I Help You" not doing your homework.

If you mean in WinForm:

1. Create 2 Methods in code behind
private void DrawRectangle()
{
   // some code 1
}
private void DrawEllipse()
{
   //some code 2
{



你不知道是什么方法吗? 方法(C#编程指南)

2.在按钮的Click事件中:



Don''t you know what method is? Methods (C# Programming Guide)

2. In Click event of Buttons:

private void button1_Click(object sender, System.EventArgs e)
{
   DrawRectangle();
}
private void button2_Click(object sender, System.EventArgs e)
{
   DrawEllipse();
}



您不了解Click事件吗? Control.Click事件

3.您应该用什么代码代替//some code1和//some code2?

在此处查看:使用C#在WinForms中使用图形绘制

=====
对不起,忘记了一些事情. (感谢SA)您还需要Control来保持绘制的形状.例如PictureBox.
当然,在阅读完最后一个链接后,您可以找到它.



Don''t you know about Click event? Control.Click Event

3. And what code should you substitue for //some code1 and //some code2 ?

Look at here: Drawing with Graphics in WinForms using C#

=====
Sorry about forgetting something. (Thanks to SA) You also need a Control to keep the drawn shapes. For example a PictureBox.
Of course after reading the last link you could find it out.


好吧,您不承认想要什么. :-)我添加此答案只是为了修复Shahin的答案.

请查看我过去的答案:
在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [如何从旧图纸中清除面板 [ ^ ],
在C#中绘制矩形 [在图片框内添加图片 [
All right, you do not confess what do you want. :-) I''m adding this answer only to fix the answer by Shahin.

Please see my past answers:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

This should explain you why not PictureBox:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

—SA


这篇关于C#绘制不同的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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