There are situations where SelectedRows won't return the number of rows preselected when using Begin/EndUpdate even though it seems like there's a row selected in the UI. By preselected I mean the row that looks selected after the rows has been added. This bug has caused some problems for us because the user tried some action on a row they thought was preselected and it would fail.
One situation I found where this bug can be reproducted is by using SortOrder in combination of Begin/EndUpdate. There are probably more situations but I hope this one will let you find the underlying bug.
The attached project contains a simple form with a RadGridView which will contain a list of persons. The list is populated by this method:
public void PopulateGridView(List<Person> persons)
{
PersonGridView.BeginUpdate();
PersonGridView.DataSource = persons;
PersonGridView.EndUpdate();
PersonGridView.Columns[nameof(Person.LastName)].SortOrder = RadSortOrder.Ascending;
}
There are two buttons: "Step one" and "Step two". The first will mimick a situation where the user search a database for persons and none will be found. By clicking the "Get selected rows" you will see that the SelectedRows will return zero rows which is correct.
But when you afterwards click "Step two" (which will add five rows) it seems like there's one row preselected. I would expect the SelectedRows to return that row but by clicking "Get selected rows" again you will see that the returned rows are zero still. The CurrentRow, however is set to the preselected row as expected.
If you start by clicking "Step two" the SelectedRows actually returns the correct rows. Quite strange :-)
I know this is a very small issue and can be avoided. But as I mentioned there are other situations where this problem occurs and it's quite hard to figure out exactly what causes it.
Thank you for your help.
Best regards
Ulrik Skovenborg