如何以一种形式从另一种形式访问图片框 - C# [英] How to access picturebox in one form , from another form - C#

查看:67
本文介绍了如何以一种形式从另一种形式访问图片框 - C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





in Form1

public PictureBox pic
       {
           get
           {
               return pictureBox1;
           }
       }


Form2中的





in Form2,

private void button5_Click(object sender, EventArgs e)
      {
          getpic();
      }


      private void getpic()
      {
          Form1 frm = new Form1();
          frm.pic.Visible = true;
      }





我尝试过:



我尝试过上面的代码。我没有得到任何错误,但它没有给出所需的输出。同样基于测试结果我需要从form2加载图像(如果传递 - tickmark.jpg,如果失败 - Xmark.jpg)。请告诉我如何实现结果。



What I have tried:

I have tried with the above code. I am not getting any error but also it doesn't gives the desired output. Also based upon the test result i need to load the image from form2 (if pass - tickmark.jpg,if fail - Xmark.jpg). Please let me know how to achieve the result.

推荐答案

这是与表单协作相关的常见问题之一。我决定写一篇提示/技巧文章,详细的代码示例和解释:一次回答的许多问题 - Windows窗体或WPF Windows之间的协作



-SA
This is one of the popular questions related to form collaboration. I decided to write a Tips/Trick article complete with detailed code samples and explanations: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows.

—SA


这篇关于如何以一种形式从另一种形式访问图片框 - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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