开发者

How to pass flag from childform to parent?

i have problem with passing boolean flag from childform to parentform.

I kn开发者_如何学Cow how to pass it from parentform to childform for example:

On mainform:

Camera settings = new Camera(this.fullPath3);
settings.ShowDialog();

On childform:

public partial class Camera : Form
    {
        //Zmienne przekazywane - sciezka do zapisu wzorca, 
        string _fullPath3;

...

  public Camera(string fullPath3)
    {

        InitializeComponent();
        _fullPath3 = fullPath3;

and it's working. How to add a bool Flag, as a return from my childform?

something like that:

On childform:

 public Camera(string fullPath3, bool flag)

On mainform:

  Camera settings = new Camera(this.fullPath3,this.flag);
  settings.ShowDialog();
  if (flag==true) text2.text="OK!";


Simple, Camera is a form so just add a public property to it.

public class Camera : Form
{
   private string _fullPath3;
   private bool flag;
    public Camera(string fullPath3)
    {

        InitializeComponent();
        _fullPath3 = fullPath3;
    }

    // set flag to something somewhere
    public bool Flag{ get{ return flag; } }

}

Now just:

Camera settings = new Camera(this.fullPath3);
settings.ShowDialog();
if (settings.Flag) text2.text="OK!";

remember that ShowDialog halts execution!


Just implement an internal or public property in your Camera form, and set this property within it.

Something like this:

  Camera settings = new Camera(this.fullPath3,this.flag);
  settings.ShowDialog();
  if (settings.Flag) text2.text="OK!";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜