.net - Add listbox items in form 1 from form 2 button pushed in c# -


i have form (form1) has listbox , button. on clicking button, opens form (form2). in form have texbox , button. on clicking button, whatever entered in textbox, should have go listbox in form1. please me find out solution.

step 1 : set modifiers property of listbox public

step 2 : in button click of form1, put

        form2 fm2 = new form2(this);         fm2.showdialog(); 

step 3: in form2, put following declaration @ top level

    private form1 _fm1;      add constructor :      public form2(form1 fm1)     {         _fm1 = fm1;         initializecomponent();     } 

step 4: in button click of form2, put following lines:

 _fm1.listbox1.items.add(textbox1.text);   this.close(); //close form2 

hope helps.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -