DataGrid Update after DataSet Change?

  • Thread starter Thread starter Paul Brown
  • Start date Start date
P

Paul Brown

Hello All,

I created a lookup table with a combobox and dataset which
works great, and then I tied the dataset to a DataGrid.
The problem is when I change the combobox the DataGrid
doesn't update. What events should I wire to get the
DataGrid to redraw after the combobox selection is changed?

Thanks,

Paul.
 
I have many datagrids with custom combo columns, based on
collections objects etc and I use this to make sure that
they are all refreshed.

It still may need some work as this is all fairly new to
me but works for me in my application. I have this In a
Static class of Various utilities...


public static void Redisplay(DataGrid dataGrid)
{
if (dataGrid != null
&& dataGrid.DataSource != null)
{

//Not sure why but if I don't do this and I add an item
to
//an empty array list that we previously bound to an
array it
//does not show up, but forcing it empty first seems to
work!!!!
object dataSource = dataGrid.DataSource;
string dataMember = dataGrid.DataMember;
dataGrid.SetDataBinding(null, "");

//Now restore the original DataBinding
dataGrid.SetDataBinding(dataSource, dataMember);

//Get the currency Manager so that we can force a refresh
CurrencyManager cm ;
cm = (CurrencyManager)dataGrid.BindingContext[
dataGrid.DataSource,dataGrid.DataMember];
//Force dataGrid to redisplay
cm.Refresh();
dataGrid.Refresh();
}
}
 
Back
Top