datagrid sorting hassles
-
Hi all, I've got a datagrid. I have a function which selects certain rows in a datagrid thus: public void selectRows(string key, string columnName) { int count = 0; foreach(DataRow dr in ((DataView)dg_aspects.DataSource).Table.Rows) { if(dr[columnName].ToString()==key) dg_aspects.Select(count); else dg_aspects.UnSelect(count); count++; } } This works, but when the user clicks a column header to sort the datagrid, the selected columns remain at the same index. For example - if the top two rows are selected initially. After sort - the top two rows are still selected, but the datagrid is showing different results in those rows. It appears that the DataTable the DataGrid is showing, and the DataDource we work with aren't the same where sorting is concerned. Does anyone know how to get a handle on the sorted DataTable? I hope that's clear - thanks for taking a look Steven
-
Hi all, I've got a datagrid. I have a function which selects certain rows in a datagrid thus: public void selectRows(string key, string columnName) { int count = 0; foreach(DataRow dr in ((DataView)dg_aspects.DataSource).Table.Rows) { if(dr[columnName].ToString()==key) dg_aspects.Select(count); else dg_aspects.UnSelect(count); count++; } } This works, but when the user clicks a column header to sort the datagrid, the selected columns remain at the same index. For example - if the top two rows are selected initially. After sort - the top two rows are still selected, but the datagrid is showing different results in those rows. It appears that the DataTable the DataGrid is showing, and the DataDource we work with aren't the same where sorting is concerned. Does anyone know how to get a handle on the sorted DataTable? I hope that's clear - thanks for taking a look Steven
Use a DataView to sort the data in the table. xacc-ide 0.0.12 now with C#, MSIL, C, XML, ASP.NET and HLSL coloring - Screenshots