Disabling Cell in Grid

2 posts, 0 answers
  1. James
    James avatar
    15 posts
    Member since:
    Feb 2016

    Posted 04 Aug Link to this post

    Need a way of disabling a checkbox cell in a unbound grid based data obtained elsewhere.


    Basically, I have a Combobox Column displaying Employee Name.  When I select a Employee, I have a 'Bonus' checkbox column that I "may" need to disable based on the Employee selected.


    Something like, I select Employee A from the 'Employee Name' column and determine if this employee is eligible to receive a bonus. If Employee is NOT eligible, I want to disable the 'Bonus' checkbox column for this row, unselect the checkbox if it is selected, and visually show that it is disabled.  If Employee is eligible the 'Bonus' column for the row should be enabled and visually show that it is enabled.


    Not exactly sure how to accomplish this and would appreciate any help anyone can provide.


    Thank you.

  2. Dess
    Dess avatar
    1561 posts

    Posted 08 Aug Link to this post

    Hello James,

    Thank you for writing. 

    Your question has already been answered in the support thread that you have opened on the same topic. However, I am posting the answer here as well in order the community to benefit from it. 

    It is suitable to use the CellFormatting event and disable the check box considering the editor's value. Here is a sample code snippet which result is illustrated in the attached gif file: 
    Sub New()
        AddHandler Me.RadGridView1.EditorRequired, AddressOf EditorRequired
        AddHandler Me.RadGridView1.ValueChanged, AddressOf ValueChanged
    End Sub
    Private Sub ValueChanged(sender As Object, e As EventArgs)
        If Me.RadGridView1.CurrentColumn.Name = "ProductName" Then
        End If
    End Sub
    Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _
    Handles RadGridView1.CellFormatting
        Dim checkBoxCell As GridCheckBoxCellElement = TryCast(e.CellElement, GridCheckBoxCellElement)
        Dim ddlEditor As RadDropDownListEditor = TryCast(Me.RadGridView1.ActiveEditor, RadDropDownListEditor)
        If checkBoxCell IsNot Nothing Then
            If ddlEditor IsNot Nothing AndAlso ddlEditor.Value = String.Empty Then
                checkBoxCell.Enabled = False
                checkBoxCell.Enabled = True
            End If
        End If
    End Sub

    I hope this information helps. Should you have further questions I would be glad to help.

    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top