Hi.
I have 2 forms in my progect.First one contains datagrid.There is a button on the second form. How to update datagrid on the first form by clicking button on the second?
Two forms and one datagrid
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Vimal KandasamyRank #2,151 · 661 reputationPosted Apr 26, 2009, 9:09 PM EDT
Set your Modifiers property of datagird as public.
and pass your current object of form1 into form2 via an overload constructor.
assign passed object to form2's form1 object.
like
//in form1
Form2 f = new Form2(this);
f.ShowDialog();
//constructor of form2
Form1 form1;
public Form2(Form1 f)
{
InitializeComponent();
this.form1 = f;
}
then in button click
access datagrid like
form1.datagrid
try this.