Hi,
After selecting multiple rows in datagridview and mouse right-click in a row other that the last row selected to view the context menu, SelectedRows.Count is reset to zero (0) as the table-row-indicator moves to the row where I initiated the mouse right-click. Rows selected remain highlighted though. Code below fails and nothing is deleted. Must right-click on the last row select. In WinForm, the table-row-indicator doesn’t change location after right-click
If I select non-contiguous rows, unselected row in deleted and selected row remains undeleted. Please see attached images.
In both instances, I am using this code:
if (dgv.SelectedRows.Count > 0) { foreach (DataGridViewRow row in dgv.SelectedRows) { if (!row.IsNewRow) { dgv.Rows.Remove(row); } } } Am I missing something? And please confirm. If a row is new (IsNewRow=true), RowHeaderMouseClick doesn't flag the row as selected and SelectedRows.Count remains zero (0). Is that by design? Thanks
Hi Luca,
#4 is now fixed in 1.2.68.0
Thanks.
I can’t reproduce 4 with my build hopefully it’s fixed and was related to the grid clearing the selection on the server and not updating the client when changing the focused cell.
/Luca
The issues I mentioned are bugs, logged and fixed – I don’t know if deployed, have to check.
I didn’t see the problem at point 4, will log as well. Thank you for the steps.
Best,
Luca
Hi Luca,
Thanks for your test app.
Sorry if I didn’t explain well what I want to drive at. I am now using your test app and made a list of the steps I did to see my point.
You said “The automatic new row is selected like any other row”. You are correct and that’s true if and only if I didn’t click any of the cells in Row 9 prior to clicking the RowHeader.
As regards to two issues you mentioned above, does it mean that there is no fix for that? WinForm handles multiple rows selection and deletion whether adjacent or non-adjacent rows using a context menu.
Actually, I resolved this deletion issue by inserting a checkbox as the first column in the grid and loop thru all the rows using a button and test the value of the checkbox. But users always look for a context menu (right-click) in a data-centric application. Just my opinion though.
Thanks.
Hi Cris,
Two issues:
The automatic new row is selected like any other row. I just tried in the test associated with this issue (attached).
Best,
Luca