winforms - Send Data Grid View data to other form in C# Windows Form Application -


i have 2 forms form1 , form2. in form1 data database , fill `datagridview' data.

customer customer = new customer(); var allcustomers = c in dc.gettable<customer>() select new getcustomers { firstname = c.firstname, lastname = c.lastname, mobile = c.mobile , customerid = c.customerid}; customerbindingsource.datasource = allcustomers; datagridview1.datasource = customerbindingsource; 

then, create event handler method customerid clicking on grid

private void datagridview1_celldoubleclick(object sender, datagridviewcelleventargs e)         {             int customer_id = list_customers[e.rowindex].customerid;             messagebox.show((customer_id).tostring());         } 

now, need send customer_id form2 information , display.

any idea how achieve this? please help

you can pass customer_id while creating instance of second form

private void datagridview1_celldoubleclick(object sender, datagridviewcelleventargs e) {      int customer_id = list_customers[e.rowindex].customerid;      secondform form2 = new secondform(customer_id); } 

and in second form can retrieve value in constructor,

 public form_2(string custid)  {     initializecomponent();     var customerid = custid;  }   

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -