add text to checkbox

2 posts, 0 answers
  1. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 28 Feb 2012 Link to this post

    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


  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Mar 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top