in form1 i have datagridview1 in form 2 i have button afer click on button how access that datagridview1
windows form c#
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 26, 2015, 1:08 PM EDT
You can then access the DataGridView (dataGridView1 say) from Form2 as follows:
// get reference to existing Form1 instance
Form1 f1 = Application.OpenForms["Form1"] as Form1;
// now get reference to dgv
DataGridView dgv = f1.dataGridView1;
// do something with dgv
Jiyalal Gupta50 reputationPosted Mar 26, 2015, 10:41 AM EDT
Aditya Chauhan121 reputationPosted Mar 26, 2015, 10:26 AM EDT
now you can perform which you want
Joginder BangerRank #360 · 7K reputationPosted Mar 26, 2015, 12:02 PM EDT
Make the click event on form2 button like this.
Jiyalal Gupta50 reputationPosted Mar 26, 2015, 12:31 PM EDT
Jiyalal Gupta50 reputationPosted Mar 27, 2015, 11:27 AM EDT
Gowtham RajamanickamRank #57 · 29K reputationPosted Apr 5, 2015, 7:24 PM EDT