Ok,
We've got a bunch of apps that we've migrated from Net 1.0 to Net 2.0.
The apps were basically upgraded using the VS2005 migrate. The user control
that was using a DataGrid.IsSelected(i) in the original (Net 1.0) to find
the 'Highlighted' rows in a datagrid is working fine.
I've tried adding the DataGrid.IsSelected(i) code into a second migrated app
to find the 'Highlighted' rows. In the 2nd program the
"DataGrid.IsSelected(i)" technique shows false for all rows both
'highlighted' and 'non-highlighted'.
So it works in the migrated program but not in the program with where I'm
trying to use it with the original DataGrid controls. I've spent most of
the day trying variations I've simply hit a brick wall with this thing.
i.e. move the code in-line and use the actual this.data_grid name, etc, etc,
etc. Can't get it to find the hightligted rows.
Any suggestions would be greatly appreciated.
I've copied in one of generic code segments that's failing. Its basically a
straight port from the migrated program that is still working. Watching
with the debugger I can see all the data in the DataGrid as the dg rows are
parsed with the 'for' loop. I usually highlight 4 or so rows in the middle
of the list. NADA. The ++iSelectedRowCount line NEVER runs.
NOTE: I understand that there is a NEW DataGridView control in Net 2.0 but
we're in the standard MAD RUSH of migrating from a UNIX DB to Sql Server
2005 AND moving all our Net 1.0 & Net 1.1 apps to Net 2.0. The app does a
BUNCH of drag-drop stuff and I'm not excited about having to replace the old
DataGrid controls with the new DataGridView controls. Could be a very deep
dark pit. Specially since this was supposed to be done yesterday.
Thanks for whatever help you can provide.
Barry
in Oregon
== Sample Code ==
private int CountSelectedDataGridRows(DataGrid pDg)
{
int i = 0;
int iSelectedRowCount = 0;
CurrencyManager cm =
(CurrencyManager)this.BindingContext[pDg.DataSource, pDg.DataMember];
DataView dv = (DataView)cm.List;
for (i = 0; i < dv.Count; ++i)
{
if ( pDg.IsSelected(i) )
{
++iSelectedRowCount;
}
}
return iSelectedRowCount;
}