[Mono-winforms-list] Clearing a datatable sourced to datagridview crashes application

sa5webber sa5webber at yahoo.com
Sat Mar 24 16:57:36 UTC 2012


I have a datagridview bound to datatable. When the first row in the datagrid
is hidden (ie. the scrollbar has moved from the top) and either of the two
following program lines is executed, the application crashes

   dataTable.Rows.Clear();
   dataTable.Clear();

My current solution is to do the following which works as a work around to
clear the bound datagridview.

   int cnt = dataTable.Rows.Count;
   for(int i=0; i< cnt; i++)
       dataTable.Rows[0].Delete();

By the way as an experiment I tried the following to move the scrollbar back
to the top. I was then going to see if that would make the
dataTable.Rows.Clear(); happy. It does if I do it manually.

   datagridView.Rows[0].Selected = true;
   datagridView.FirstDisplayedCell = datagridView.CurrentCell;

In MS.net this moves the scrollbar to the top. In mono these lines seem to
be ignored.



--
View this message in context: http://mono.1490590.n4.nabble.com/Clearing-a-datatable-sourced-to-datagridview-crashes-application-tp4501703p4501703.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.


More information about the Mono-winforms-list mailing list