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

[Solved] Prevent the ability to click underlying cell in Column with Checkbox

2 Answers 43 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Timothy
Top achievements
Rank 1
Timothy asked on 09 Dec 2010, 01:19 AM
I have a custom column defined as below,

Imports System
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Ink
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports Telerik.Windows.Controls
Imports Telerik.Windows.Controls.GridView
Imports System.Windows.Controls.Primitives
  
Public Class CustomColumn
    Inherits GridViewDataColumn
  
  
    Public Overrides Function CreateCellElement(ByVal cell As GridViewCell, ByVal dataItem As Object) As FrameworkElement
        Dim cb = TryCast(cell.Content, CheckBox)
          
        If cell.Value IsNot Nothing Then
            If cb Is Nothing Then
                cb = New CheckBox()
                cb.Height = 20
                cb.SetBinding(CheckBox.IsCheckedProperty, Me.DataMemberBinding)
                cell.Content = cb
                cell.SetBinding(GridViewCell.ValueProperty, Me.DataMemberBinding)
            End If
        Else
        End If
  
        If cell.Value = "True" Then
            cell.Background = New SolidColorBrush(Colors.Green)
        ElseIf cell.Value Is Nothing Then
            cell.Background = New SolidColorBrush(Colors.LightGray)
            'cell.IsEnabled = False
        End If
        Return cb
    End Function
End Class

I have also defined custom actions when the checkbox is checked, unchecked. However I need to prevent the underlying cell (the area around the checkbox) from being able to be clicked as it is causing issues with my application. I only want the user to be able to modify the state of the checkbox and not be able to click the cell around it. Is this possible.

Please help.

Thanks,
Tim

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 09 Dec 2010, 08:04 AM
Hello Timothy,

You may try to set the IsReadOnly property of the column to "True". 

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Timothy
Top achievements
Rank 1
answered on 09 Dec 2010, 09:04 AM
Thank you. That works perfectly. Surprised I never thought of it. I was running around in circles.

Thank you so much!
Tags
GridView
Asked by
Timothy
Top achievements
Rank 1
Answers by
Maya
Telerik team
Timothy
Top achievements
Rank 1
Share this question
or