You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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() 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().
Activity
itg-assistant commentedon Jun 12, 2026
Frank (ITG) answered 2017-01-21 11:40:27 UTC
Thanks Marian !
I have logged the bug as WJ-7956 and we will inform you when it is fixed.
Best regards
Frank
itg-assistant commentedon Jun 12, 2026
Frank (ITG) answered 2017-01-22 21:12:40 UTC
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