Hi,

I have a c# windows form app that hanldes memberships. When the user click "new member" a second form pops up where the user can enter in the new data using the details view. When complete the user saves and closes this second form, returning to the original form which has a dataGridView.

What I'm struggling with is a way to force the original form to refresh once the new information has been entered. The nearest I have come is to have either a button the user can click which refills the data table or to have the refill tied to a timer based event. both of those arent particularly good.

Can anyone help?

thanks

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);
        }
    }

Hi thanks for your post!

yes its populated via a data table/set. something like...

this.membersTableAdapter.Fill(this.dsMemberWithNotes.Members);

this currently sits within the MainForm_Load method

This article has been dead for over six months. Start a new discussion instead.