This is a migrated thread and some comments may be shown as answers.

Unselect cell programmatically?

2 Answers 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Esteban
Top achievements
Rank 1
Iron
Esteban asked on 04 Sep 2018, 01:42 PM

Hello!

I need to deselect only one cell once selected.
I have tried the following code in the SelectionChanged and SelectionChanging events. But it does not work.

Any suggestions?

RadGridView1.CurrentCell.IsSelected  = false

 

 

Thanks.

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Sep 2018, 09:36 AM
Hello, Esteban,         

The SelectionChanging event is fired before actually the selected row is changed. You can cancel this event in order to prevent the row specified in the event arguments to be selected. Simply set the Cancel argument to true.

The following help article demonstrates how to select certain rows programmatically: https://docs.telerik.com/devtools/winforms/gridview/selection/selecting-rows-and-cells-programmatically

I am not sure why exactly you try to unselect a cell in the SelectionChanged event. However, have in mind that if you manipulate the IsSelected property in this event it will be triggered again. I can suggest you to cancel the SelectionChanging event when you try to prevent a certain cell to be selected you unselect the cell programmatically on a button click. If you are still experiencing any further difficulties, it would be greatly appreciated if you can provide additional information about the exact goal that you are trying to achieve. Thus, we would be able to think about a suitable solution.

I hope this information helps. If you have any additional questions, please let me know.  
 
Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Esteban
Top achievements
Rank 1
Iron
answered on 05 Sep 2018, 11:20 AM

Thanks!

Private Sub RadGridView1_SelectionChanging(sender As Object, e As CancelEventArgs) Handles RadGridView1.SelectionChanging
     If ...condition … then
              e.cancel
    End If
End Sub
Tags
GridView
Asked by
Esteban
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Esteban
Top achievements
Rank 1
Iron
Share this question
or