DataGridView SelectedRows not updating correctly

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

Hi,

I’ve found a problem in the DataGridView.SelectedRows property.  In the attached example, if you select all the rows (10 in total), then press that button to get the number of selected rows, you will see a 10 displayed, which at that point is correct.  If you then select just one row then press that button again, it still says that there are 10 rows selected.

Also, I noticed that if i setup a foreach loop over the SelectedRows after selecting one row at a time, e.g. rows 1,3 and 6, with row 6 being the only row selected, the SelectedRows property will show that there are 3 rows still selected when there is only the one.  This problem also occurs using a for loop over the grid.Rows property, i.e. it retains the previously selected rows when there is only 1 row selected.

 

Attachment
  • You must to post comments
0
0

Thanks, both issues are fixed in the release build coming up later today.

  • Luca (ITG)
    It’s actually the same issue, introduces in the development build because of a speed optimization in DGV.ClearSelection().
  • You must to post comments
0
0

Recognized the same issue after updating to Version 1.3.62.0. I use “MultiSelect = False” on grid but every row I’ve clicked is marked as “Selected = True” and the property doesn’t change to “False” any more.

 

private void dgvEMails_SelectionChanged(object sender, EventArgs e)
{
try
{
Wisej.Web.DataGridView grid = (Wisej.Web.DataGridView)sender;
Wisej.Web.DataGridViewRow row = grid.SelectedRows[0];
EmailMessage msg = (EmailMessage)row.DataBoundItem;
htmlPanel.Html = msg.Body;
}
catch (IndexOutOfRangeException)
{
return;
}
}

 

For “Singleselect” I changed my code from

“Wisej.Web.DataGridViewRow row = grid.SelectedRows[0];”

to

“Wisej.Web.DataGridViewRow row = grid.CurrentRow;”

  • Andrew Hills
    Thanks for that, i’ll keep that in mind for a shortcut for single select.
  • You must to post comments
Showing 2 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json