How do you populate the users list on main form? Is it from a DataTable (or dataSet) or some array list?
You can use a delegate to pass the data from one form to another, and refreshing the gdv control with calling the method to populate it.
YOu can take a look into this simple example, wgich shows how to pass data from one form to another (from textBox to a label) - you can do the same, only to pass the data to some other method, which would populate dgv (or add a new row to it):
//FORM1:
public partial class Form1 : Form
{
delegate void MyDelegate(string str);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2(this);
form2.Show(this);
}
public void PassingParameters(string item)
{
if (label1.InvokeRequired)
{
MyDelegate d = new MyDelegate(PassingParameters);
label1.Invoke(d, new object[] { item });
}
else
label1.Text = item;
}
}
//FORM2:
public partial class Form2 : Form
{
Form1 form1;
public Form2(Form1 _form1)
{
InitializeComponent();
form1 = _form1;
}
private void button1_Click(object sender, EventArgs e)
{
string item = textBox1.Text;
form1.PassingParameters(item);
}
} Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474