C#Form1文本框在Form2 PictureBox上绘制文本 [英] C# form1 textbox text draw on form2 picturebox

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

问题描述



有人帮我下面的代码
我在form1上有textbox.text和button1
form2图片框

如果我单击form1按钮,则应该在textbox.text
中输入的form2图片框form1上进行打印或绘制.
谢谢



anybody help me the below code
i have textbox.text and button1 on form1
form2 picturebox

if i click form1 button it should be print or draw on form2 picturebox form form1 entered in textbox.text

thanks

推荐答案

Don''t.通过方法或属性将文本传递到Form2,并绘制文本.
这样,Form2不需要知道Form1存在,它就可以继续工作了.因此,如果以后需要对Form2进行更改,则不必考虑对其他窗体的影响.

确切的操作方式取决于表单之间的关系".本质上,如果FormX创建FormY的实例,则FormX是父",而FormY是子",并且处理通信的确切方式也有所不同,因为父"需要了解子",但是孩子"不需要知道它的父母"或其他孩子".
看看这些:
在两种形式之间传输信息,第1部分:父级到子级 [ ^ ]
在两种形式之间传输信息,第2部分:子代给父母 [ ^ ]
在两种形式之间传输信息,第3部分:子对子 [ ^ ]
Don''t. Pass the text to Form2 - via a method or a property - and have it draw the text.
That way, Form2 doesn''t need to know Form1 exists, it just gets on with the job. So if you need to make changes to Form2 later, you don''t have to consider the effects on other forms.

Exactly how you do it depends on the "relationship" between the forms. In essence if FormX creates an instance of FormY, then FormX is the "Parent" and FormY is the "Child", and exactly how to handle the communications differs according to that, as a "Parent" needs to know about "Children", but "Children" don;t need to know about it''s "Parent" or other "Children".
Have a look at these:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]


这篇关于C#Form1文本框在Form2 PictureBox上绘制文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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