C # WinForm a value between forms

Source: Internet
Author: User

1. The parent form passes values to the subform:

Parent form:

1  New FRM Cash Bank code (1,0); 2   This ; 3  frm. ShowDialog ();

Subform:

1    int 0 ;       2          Public FRM Cash Bank code (int ty,int  IND)3        {4             InitializeComponent (); 5             type = ty; 6             index = ind; 7         }

Data Update:

1    Private void renovate () 2         {3             new  frm cash Bank (); 4             frm = (frm cash bank)this. Owner; 5             frm. BINDDGV ();  BINDDGV is the data in the parent form binding DGV,6         }
1  Private voidbtnSearch_Click (Objectsender, EventArgs e)2        3               ... Data deletion and Modification code4                 if(Res. Success) {5 renovate ();6                      This. Close ();7                 }8             Else9             {TenUtility.error ("Add failed:"+Res. ERRMSG); One}

2. The subform passes the value to the parent form

Parent form:

1  Private voidPb_wharehouse_click (Objectsender, EventArgs e)2         {3frm Warehouse Query frm =Newfrm warehouse query ();4frm. p_value+=Frm_e_value;5 frm. ShowDialog ();6         }7         voidFrm_e_value (stringvalue)8         {9Txt_wharehouse. Text =value; Values passed from the subformTen}

Subform:

1    Public Delegate voidT_value (String Value);2    Public EventT_value E_value;3   Private voidBtn_selected_click (Objectsender, EventArgs e)4         {5E_value ( This. Txt_lx. Text);6              This. Close ();7 8}

C # WinForm a value between forms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.