Link to home
Start Free TrialLog in
Avatar of viola123
viola123

asked on

How to refresh a DataGridView?

All,
i have a datagridview, the data source of it is a List. what i want to do are:
1. Add new data to the list
2. bind the list to dataGridView
3. refresh the dataGridView
example:
lstGrpMaster.Add(Master1);
dataGridViewMaster.DataSource = _lstGrpMaster;
dataGridViewMaster.Refresh();

the above code does not work. Do you have any idea?
thanks a lot
viola
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Hi viola,

Instead of dataGridViewMaster.Refresh(), use dataGridViewMaster.Databind().

Regards,

Wayne
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forgot to ask, is this windows or web?

I assumed it's windows because windows grid is called dataGridView and the web GridView have no Refresh method.
Avatar of viola123
viola123

ASKER

All,
thanks. i figured it out, you have to set the datasource to Null first and then assign the datasource again.

AlexCode: it is windows application.

nevermind, stupid question. I had the dataset size set incorreclty. Thanks