


C#中Form2窗体调用Form1窗体中的空间值(窗体之间传递值方法)
现象:需要将窗体1中的文本控件值传递到窗体2中图片控件中使用,代码如下:
Form1窗体代码:
- public static string str;
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- Form2 f2 = new Form2();
- str = textBox1.Text;
- f2.ShowDialog();
- }
Form2窗体代码:
- private void Form2_Load(object sender, EventArgs e)
- {
- Form1 f1 = new Form1();
- pictureBox1.LoadAsync(Form1.str);
- }



亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论