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

add text to checkbox

1 Answer 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason Parrish
Top achievements
Rank 1
Jason Parrish asked on 28 Feb 2012, 05:13 PM
I can't seem to have the checkbox column cells to display any text.  Is it even possible?    The code below does not work.  The radcheckboxeditorelement does have a DisplayStyle property like the radcheckbox.  Please advise.  Do you I need to to do a custom celltype?

Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
 
    If e.Column.Name.ToUpper = "AGREE" AndAlso TypeOf e.CellElement Is GridCheckBoxCellElement Then
        CType(e.CellElement.Children(0), RadCheckBoxEditorElement).Text = "I Agree"
    End If
 
 
End Sub


1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Mar 2012, 03:00 PM
Hi Jason,

Thank you for writing.

RadCheckBoxEditorElement does not have a functionality to paint text. It is created to display just the check mark. However, you requirement can be achieved by moving the check mark to the left of the cell, set some paddings, and set the text to the CellElement:
Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
 
       If e.Column.Name.ToUpper = "AGREE" AndAlso TypeOf e.CellElement Is GridCheckBoxCellElement Then
           e.CellElement.Text = "I Agree"
           CType(e.CellElement.Children(0), RadCheckBoxEditorElement).Checkmark.Alignment = ContentAlignment.MiddleLeft
 
           CType(e.CellElement.Children(0), RadCheckBoxEditorElement).Padding = New Padding(-15, 0, 0, 0)
           e.CellElement.Padding = New Padding(15, 0, 0, 0)
       End If
 
   End Sub

I hope that you find this information helpful.
 
Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Jason Parrish
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or