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

Making a check box in the grid column invisible.

5 Answers 239 Views
GridView
This is a migrated thread and some comments may be shown as answers.
RAGHAVENDRA
Top achievements
Rank 1
RAGHAVENDRA asked on 07 Jan 2011, 08:37 PM
Hello All,
I have a column in the grid view with Checkboxes. Now my requirement is that i need to make some of the check boxes visible or invisible while binding the RadGridView. I am not able to figure out a way of doing it. Any help would be greatly appreciated. 
 ''' <remarks></remarks>
    Private Sub RadGridViewBrokenRuleMessages_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridViewBrokenRuleMessages.CellFormatting
        If e.CellElement.ColumnIndex = 2 Then
            If Me.RadGridViewBrokenRuleMessages.CurrentRow.Cells(0).Value.ToString().ToUpper(System.Globalization.CultureInfo.CurrentCulture) = "1" Then
                e.CellElement.ColumnInfo.ReadOnly = True
            Else
                e.CellElement.ColumnInfo.ReadOnly = False
            End If
        End If
    End Sub

Is it possible to do that in here. Also if you can tell me where to do that or some sample on where to do that would be very helpful.

5 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Jan 2011, 12:40 AM
Hello,

Yes, you can hide the checkbox depending on the value of another cell in the CellFormatting event. Please have a look at this sample.
Private Sub RadGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
    If TypeOf e.CellElement Is GridCheckBoxCellElement Then ' If its a Checkbox cell
        If e.CellElement.RowInfo.Cells("Id").Value IsNot Nothing Then ' and teh Id column (for exmaple) is not null
            If Convert.ToInt32(e.CellElement.RowInfo.Cells("Id").Value) = 1 Then ' If the Id is 1
                e.CellElement.Visibility = ElementVisibility.Collapsed
            Else
                e.CellElement.Visibility = ElementVisibility.Visible
            End If
        End If
    End If
End Sub

Hope that helps. Let me know if you need more info
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 10 Jan 2011, 10:16 AM
Hello,

Did this help? If so, please remember to mark as answer. If you need more assistance, do let me know.
thanks
Richard
0
RAGHAVENDRA
Top achievements
Rank 1
answered on 11 Jan 2011, 05:48 PM
Thanks a lot it helped!!!1
0
RAGHAVENDRA
Top achievements
Rank 1
answered on 11 Jan 2011, 05:49 PM
Also sorry for the delay... dint check back till today..!!
0
Richard Slade
Top achievements
Rank 2
answered on 11 Jan 2011, 05:52 PM
Glad that helped.
All the best
Richard
Tags
GridView
Asked by
RAGHAVENDRA
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
RAGHAVENDRA
Top achievements
Rank 1
Share this question
or