hey everyone new user here. I am currently experiencing a problem in C# in which I have no idea how to effectively combat.

Basically, I'm building an application which allows the user to create clients in one form. Once the client is created the client object is added to a list, then the lists items are shown in rows in a DataGridView control. A user can then select a client in the DataGridView and click a button in order to edit the client. A new form pops up filled with or the controls necessary to perform the edit. The user changes what they want then proceeds to click a button which updates the item in the list, and is then suppose to update/refresh the DataGridView in the main form.

The editing of the actual client object works perfectly fine, the objects state is being changed, however the DataGridView is simply not being refreshed from the edit form. In order to update it, I need to re-add the list of clients to the DataGridView. I feel it has something to do with how I am accessing the DataGridView from the EditForm.

The list of Clients is stored in its own class:

public static class Clients
{
public static List<Client> clients = new List<Client>();
}

Here is the property for the DataGridView in my main form code:

public DataGridView DataGridViewProp
{
get{return dgvClient;}
set{dgvClient = value;}
}

Here is the method I am using to Update the DataGridView (the method is located within the Client class)

public static void DisplayClients(List<Client> cList, DataGridView dgv)
{
dgv.Rows.Clear();

foreach (Client c in cList)
{
dgv.Rows.Add(c.id_, c.firstName_, c.lastName_, c.homeAddress_, c.workAddress_,
c.emailAddress_, c.homePhoneNumber_, c.cellPhoneNumber_);
}
}

Here is where I am trying to Update/Refresh the DataGridView in the Edit Form

private mainForm mForm = new mainForm();

private void buttonUpdate_Click(object sender, EventArgs e)
{
try
{
Clients.clients[Index.clientIndex[0]].FirstName = firstNameText.Text;
Clients.clients[Index.clientIndex[0]].LastName = lastNameText.Text;
Clients.clients[Index.clientIndex[0]].HomeAddress = homeAddressText.Text;
Clients.clients[Index.clientIndex[0]].WorkAddress = workAddressText.Text;
Clients.clients[Index.clientIndex[0]].EmailAddress = emailAddressText.Text;
Clients.clients[Index.clientIndex[0]].HomePhone = Convert.ToInt64(homePhoneText.Text);
Clients.clients[Index.clientIndex[0]].CellPhone = Convert.ToInt64(cellPhoneText.Text);
Clients.clients[Index.clientIndex[0]].Assignment.Description = descriptionText.Text;
Clients.clients[Index.clientIndex[0]].Assignment.IssueDate = newIssue.Value;
Clients.clients[Index.clientIndex[0]].Assignment.DueDate = newDue.Value;
Client.DisplayClients(Clients.clients, mForm.DataGridViewProp);
MessageBox.Show("Client successfully updated/edited");
}
catch (Exception error)
{
MessageBox.Show("Unable to update/edit the client: " + error.Message);
}
}

I repeat, the actual modification of the selected item in the List<Client> is working perfectly, the DataGridView simply isn't refreshing from the EditForm.

I'm sure this has a really simple fix, I just cannot for the life of me find a solution.

any help is greatly appreciated. If more code is required just let me know.

Thanks in advance everyone,
mafro