General information
Category:
The Mere Mortals .NET Framework
Title:
MmDataGrid.GetSelectedRows returning too many rows
Environment versions
Network:
Windows 2000 Server
Hi,
Does mmDataGrid.GetSelectedRows empty its rows when a new single row is selected in a datagrid? I ask because I am getting more than one row in the 'selected rows table' returned from GetSelectedRows after I have selected and deselected a few rows in an mmDataGrid.
To reproduce
--------------------------
1. Select a row in a mmDataGrid.
2. Check the rowcount of mmDataGrid.GetSelectedRows().Tables[0].Rows.Count
3. Select a different row
4. Again, check the rowcount of mmDataGrid.GetSelectedRows().Tables[0].Rows.Count
Thanks in advance,
Andrew
UPDATE : After a little more research I can almost answer my own question :
Looks like mmDataGrid.SelectedRows.Clear is only performed if the mmDataGrid is NOT MultiSelect and you click on the header (see mmDataGrid.cs Method OnMouseDown() LOC 1068 to 1107).
Reproduce (If you have created the Order System CSharp project from the MM Net Development Guide) :
-------------------------------------------------------------------------------------------------------------------------
1. Set a Label on the CustomerOrdersForm
2. In the grdOrders mmDataGrid's onClick event, set the following code :
StringBuilder sb = new StringBuilder();
foreach(object obj in this.grdOrders.SelectedRows)
{
sb.Append(obj.ToString() + " ");
}
this.label1.Text = sb.ToString();
3. Enter "FRANS" in the customerID picker and hit TAB.
4. Randomly select rows in the orders datagrid and see what the label says.
The expected behavior (at least for me) is that the label will contain the index of the currently selected row(s). When I do this test then the index numbers are not reset each time I chose another row. Multiple select also seems to not yeld the correct index numbers for the currently selected rows.
Sincerely,
Andrew
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only