Product Information
- Product: Telerik UI for WinForms
- Control: RadGridView
- Version: 2025 Q4
Desired Behavior
When multiple rows are selected, I would like to deselect only the clicked row if the user clicks a row that is already selected.
Current Implementation
I implemented the following logic in the event:CurrentRowChanging
}
Behavior Observed
Case 1
Initial state:
- Row A, Row B, and Row C are selected.
- CurrentRow = Row A.
Action:
- Click Row B.
Result:
- Row B is deselected.
- CurrentRow remains Row A.
- The visual state is updated correctly and Row B is no longer highlighted.
This works as expected.
Case 2
Initial state:
- Row A, Row B, and Row C are selected.
- CurrentRow = Row A.
Action:
- Click Row A (the CurrentRow itself).
Result:
- Row A is removed from the selection.
- The row is no longer contained in .
SelectedRows - However, the entire row remains highlighted in blue.
Investigation Results
I confirmed that is not fired when the user clicks the CurrentRow itself, since the current row is not changing.CurrentRowChanging
After clicking the CurrentRow, I checked the following properties:
radGridView1.SelectedRows.Contains(row) == false
Therefore, the row appears to be completely deselected internally.
Additional Tests
I tried forcing UI updates using the following methods, but the visual appearance did not change:
radGridView1.TableElement.Update(GridUINotifyAction.StateChanged);
radGridView1.TableElement.Invalidate();
radGridView1.Refresh();
Question
Although the row is no longer selected:
radGridView1.SelectedRows.Contains(row) == false
the entire row remains highlighted in blue.
Is this expected behavior caused by the CurrentRow/Focus visual state, or could this be a rendering issue?
Additionally, is there a recommended way to achieve the following behavior?
- Keep the CurrentRow unchanged.
- Preserve the remaining selected rows.
- When the CurrentRow is clicked again, remove its visual selection highlight so that it appears deselected.
Any guidance or recommended approach would be greatly appreciated.
Thank you.
---------------------------------------------------
The issue looks like it can be resolved with the following code:
private void GridView_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (e.RowElement.RowInfo.IsSelected)
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
e.RowElement.DrawBorder = true;
e.RowElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
}
else
{
e.RowElement.DrawFill = false;
e.RowElement.DrawBorder = false;
}
}
private void GridView_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.RowInfo.IsSelected)
{
e.CellElement.DrawFill = true;
}
else
{
e.CellElement.DrawFill = false;
}
}
However, the ">" indicator for the CurrentRow and the border that remains around the selected cell are still displayed.
Is there a way to remove these as well?
Please refer to the attached image.
