TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ari
NA
8
51k
Refreshing a DataGridView in one form from another
Dec 2 2011 9:24 PM
Hey I have a form which contains a DataGridView which items are bound via a List. From there, I can edit a selected rows items by clicking a button which opens a new form which contains textboxes, combo boxes etc. Once I've finished editing the data, I close the edit form using a button, which takes me back to the main form. Now, once I exit the edit form, the DataGridView is suppose to have its items refreshed so that the updated items are displayed. At the moment, the editing is working fine, however the datagridview is not refreshing. However, if i simply rebind the list in the main form it works, it should work from the edit form but it simply isn't.
Here is a snippet of code from the edit form exit button which is suppose to be doing the refreshing:
MessageBox.Show("Client successfully edited");
Client.DisplayClients(Clients.clients, mForm.DataGridViewProp);
mForm.DataGridViewProp.EndEdit();
mForm.DataGridViewProp.Refresh();
mForm.DataPanel.Refresh();
this.Close();
mForm is an instance of the main form:
private mainForm mForm = new mainForm();
Clients.clients is a List within a class, and DisplayClients is a method 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_);
}
}
Any help on the matter is greatly appreciated.
Thanks,
Ari
Reply
Answers (
3
)
Access form from another class in c#
How to add CheckBox into ListBox