Thread filling DataSet bounded to DataGrid with my own DataGridCol

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have such a problem… I have create my custom DataGridColumn inheriting from
System.Windows.Forms.DataGridColumnStyle on using it on DataGrid, to show
rows painted by me self. Because dates taken from database are very large,
and filling DataSet bounded to this DataGrid takes some time, a decided to
put fill logic into new thread. And so method running in this thread clears
only this DataSet bounded to DataGrid and fills it once more time using
SqlDataAdapter. The user have got “Refresh†button, so he could fire this
Thread. And there is a problem. When I call this method, there are same
strange things going with my application… in almost cases DataGrid shows to
scroll bars, any of them aren’t active, they don’t response for moving, or
click up, down buttons, there aren’t any showing dates in my DataGrid…
sometimes application blokes, or throwing unhandled exception…
Any suggestions… ???

Regards…

Krzysztof Karnicki
 
The problem is, when the thread is filling the dataset, the dataset is firing events to the datagrid and these are arriving ont the background thread. So your UI is being updated on a background thread which is unsupported in the underlying windowing system Create another dataset, then use the BeginInvoke method of the datagrid to marchal a call oin to the UI thread that rebinds the datagrid to the new dataset.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

I have such a problem… I have create my custom DataGridColumn inheriting from
System.Windows.Forms.DataGridColumnStyle on using it on DataGrid, to show
rows painted by me self. Because dates taken from database are very large,
and filling DataSet bounded to this DataGrid takes some time, a decided to
put fill logic into new thread. And so method running in this thread clears
only this DataSet bounded to DataGrid and fills it once more time using
SqlDataAdapter. The user have got "Refresh" button, so he could fire this
Thread. And there is a problem. When I call this method, there are same
strange things going with my application… in almost cases DataGrid shows to
scroll bars, any of them aren't active, they don't response for moving, or
click up, down buttons, there aren't any showing dates in my DataGrid…
sometimes application blokes, or throwing unhandled exception…
Any suggestions… ???

Regards…

Krzysztof Karnicki
 
Back
Top