DataGridView row selection bug.

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

Hello,

I think I found a bug regarding the DataGridViewRow.Selected property. It appears that changing the grid DataSource and immediately setting the Selected property of a row has no effect (at least within the CellClicked event). It seems to always select the first row of the grid.

I’ve attached a project showing the issue.

Attachment
  • You must to post comments
0
0

Hi Marian,

we have checked in more detail and found that in fact it´s not a bug.

When changing the data source the focus cell is reset which causes the selection to be cleared. Works the same in WinForms. In fact in WinForms it’s impossible to change the selected rows right after changing the data source.

With Wisej it is possible thanks to its asynchronous nature. Change the sample code to:

BeginInvoke(newAction(() =>

{

// Restore selection.

foreach (DataGridViewRow row inthis.dataGridView1.Rows)

{

if (selectedItems.Contains(row.DataBoundItem))

{

row.Selected = true;

Debug.WriteLine($”{row.DataBoundItem} selected.”);

}

else

{

row.Selected = false;

}

}

}));

BeginInvoke() in Wisej is executed within the same request and on the same thread but *after* the entire request has been completed. It’s basically a post-process callback. It allows an application to execute code asynchronously. Which is different from Application.StartTask().

Hope that helps.

Best regards
Frank

  • You must to post comments
0
0

Thanks Marian !

I have logged the bug as WJ-7956 and we will inform you when it is fixed.

Best regards
Frank

  • 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