如何在Form_Load的表单中绘制一条线? [英] How to draw a line in Form_Load of a Form?

查看:93
本文介绍了如何在Form_Load的表单中绘制一条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Form上从一个点到另一点画一条线,并在Form_Load()事件(不使用Paint事件)中对其进行编码:

I want to draw a line from one point to another on a Form and code it in Form_Load() event (not use Paint event):

private void Form1_Load(object sender, EventArgs e)
        {
            Pen pen = new Pen(Brushes.Blue,1);
            Graphics m = this.CreateGraphics();
            m.DrawLine(pen, 0, 0, 100, 100);
        }



但是当我跑步时,我没有任何结果!为什么?希望你能帮助我解决这个问题.谢谢.



But when i run, i dont get any result! Why? Hope you help me solve this problem. Thanks.

推荐答案

请参阅我对问题的评论.这根本不是Forms和System.Drawing的工作方式.请查看我过去的答案:
在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [
Please see my comment to the question. This is not how Forms and System.Drawing work, not at all. 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(...))[^].

—SA


这篇关于如何在Form_Load的表单中绘制一条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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