8 Answers, 1 is accepted
You need to set the CurrentRow to null:
private
void
RadButton2_Click(
object
sender, EventArgs e)
{
radGridView1.CurrentRow =
null
;
}
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Progress Telerik
Hello, Francis,
According to the provided brief information, it is not clear enough what is the exact scenario that you have on your end and how exactly you use the ClearSelection method? I have noticed that you have opened a support ticket on the same topic. Please see the reply there. Please, see our answer there for more information.
We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. Thank you for your understanding.
However, I am posting the reply here as well in order the community to benefit from it. While the grid is in a BeginUpdate/EndUpate block, its updates are suspended. Hence, clearing the selection or setting the CurrentRow may not take effect. These actions have to be performed after calling the EndUpdate method.
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
No this one is different than the open ticket i have. I have a simple button on a new form we are trying to unselect a selected item and clear some textbox. Doing Grid.ClearSelection() do nothing. The row stays highlighted. I have fullrowselect and when selected the whole row is orange.
When i call the Grid.ClearSelection() the cell that was clicked stays Orange and all the other return as "unselected" and it also keep a big orange border around the fullrow. Doing CurrentRow = null clear the visual highlight (selection) properly.
What i suggest is to put CurrentRow = null in the source code of Grid.ClearSelection() so it does actually clear the selection visually as well.Again this is without any begin/end update.
Here i have attached the example of what happen on the first grid i found.
1 - I clicked a grid cell of a grid with fullrowselect.
2 - click a temp button i just made up on the form
private void btnTest1_Click(object sender, EventArgs e) { grdProducts.ClearSelection(); }
3 - Second image show the result of that. The previously "clicked" cell stays selected and a full selection around the complete row still there. The row is still selected despite calling a method call "ClearSelection"
4 - Repeated step 1 where i clicked the same cell and click a second button i just created but with 2 lines of code. ClearSelection and CurrentRow = null.
private void btnTest2_Click(object sender, EventArgs e) { grdProducts.ClearSelection(); grdProducts.CurrentRow = null; }
The third section of the image show the result that CurrentRow is mandatory to unselect a grid row all the time. Hence why i point out why it should be included automatically so people just don't fall into the trap in the future thinking a method does what it name says. Or maybe create a method intuitively called "ClearVisualSelection" that in the code behind does the "CurrentRow = null". Would have saved me ton of time figuring out the issue that's it.
The provided screenshot was greatly appreciated. It helped me to understand better the undesired behavior that you are facing.
I would like to note that RadGridView may have one or more selected rows/cells and only one current row/cell. Selected and Current state of the row are two different indications for the row and they are purposed to handle different cases: https://docs.telerik.com/devtools/winforms/controls/gridview/rows/selected-rows-and-current-row
Clearing the selection is expected to clear the selected rows/cells but the current row/cell remains. That is why you see the border around the row and the orange fill color for the current cell. This is expected behavior.
If you need to clear both, selection and current row, you need to call ClearSelection and set the CurrentRow to null.
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
So for you guys something highlighted doesn't mean selected. I seriously took less than 2 hours after someone did a release with this piece of code to get over 40 complains from user telling us we did not remove the selection. Sorry but i have to say this is a very bad design. For decades highlighted object meant selected. Users as used to that, it even confused me for couple hours and i have over 30 years experience in programing.
Just saying i fixed the issue with CurrentRow=null and that's okay but you guys might want to do actual user support with real end user and know the reality is for users.
Hello, Francis,
The provided feedback is greatly appreciated. I am really sorry to hear that you were experiencing difficulties with this functionality.
Indeed, there is different style for the current and selected state of the row/cell. This depends on the design for the specific theme that we have, but the current cell is always indicated with a fill color and the current row has a border around it. Setting the CurrentRow to null is expected to achieve the design you need. Feel free to use it.
If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik