没有从代码中画出任何线条 [英] No line is drawn from the code
本文介绍了没有从代码中画出任何线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
为什么没有在屏幕上用以下代码绘制一条线??
Hi there,
Why doesn''t a Line get drawn on the screen with below code???
//Declaration
public Graphics obj_Graphics;
private Bitmap obj_Bitmap;
//Coding
obj_Bitmap = new Bitmap(1000, 1000);
obj_Graphics = Graphics.FromImage(obj_Bitmap);
obj_Graphics.DrawLine(new Pen(new SolidBrush(Color.Black), 5), 100, 500, 400, 500);
在此先感谢...
Thanks in advance...
推荐答案
您正在使用一些声明为自己的对象.它们在内存中,但不在屏幕上.看看一个简单的示例的链接,该链接在处理表单时如何执行:
http://www.geekpedia.com/tutorial50_Drawing-with-Csharp.html [ ^ ]
如果要使用网页上创建的内容,请查看以下链接:
http://msdn.microsoft.com/en-us/library/system. web.httpresponse.outputstream.aspx [ ^ ]
祝您好运!
You are using some objects you declared yourself. These are in memory but not on screen. Have a look at the link for a simple example how to do it when working with forms:
http://www.geekpedia.com/tutorial50_Drawing-with-Csharp.html[^]
If you want to use the created content on your web page, have a look at this link:
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.outputstream.aspx[^]
Good luck!
因为您不在屏幕上绘制,所以您正在绘制位图:
Because you are not drawing on the screen, you are drawing on a bitmap:
obj_Graphics = Graphics.FromImage(obj_Bitmap);
如果要在屏幕上绘制它,请处理窗体或窗体上的面板的Paint事件,并使用在EventArgs参数中处理的Graphics对象:
If you want to draw it i=on teh screen, then handle the Paint event for your form, or a panel on your form and use the Graphics object you are handled in the EventArgs parameter:
e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Black), 5), 100, 500, 400, 500);
这篇关于没有从代码中画出任何线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文