How can I pass values from one form to another?

前端 未结 10 2597
野的像风
野的像风 2020-12-02 00:43

Consider the situation where I have two windows forms, say F1 and F2. After using F1, I have now called F2.ShowDialog().

10条回答
  •  清歌不尽
    2020-12-02 01:33

    Has anyone considered simply passing the value to the form in the tag attribute.

    Form newForm = new form();
    newForm.Tag = passValue;
    newform.showmodal();
    

    when newform is shown the load (or any other) routine can use the data in tag

    public void load()
    {
      if (this.Tag.length > 0)
      {
         // do something with the data
      }
    }
    

提交回复
热议问题