How to set Column Header height?

10 posts, 0 answers
  1. Pawz
    Pawz avatar
    51 posts
    Member since:
    Aug 2007

    Posted 29 Aug 2008 Link to this post

    It's a pretty simple question - how do I set the height of my column headers? I've got a dataset that loads up with a 3-line header, but it gets cut off. I can't seem to find the right area to make the column header larger....

    ie Column Header Text:

    [3600 x
    1200 x
    3000  ] <------ This gets cut off
    [ row  ]
    [ row  ]
    [ row  ]


  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 29 Aug 2008 Link to this post

    Hi Pawz,

    Thank you for writing.

    You can get or set the height of the column header row by using the code below:
    (this.radGridView1.GridElement as GridTableElement).TableHeaderHeight = 100; 

    You can also access the TableHeaderHeight property at design-time by using RadGrid's Smart Tag (click on the "Edit UI elements" and locate GridTableElement in the hierarchy).

    If you have any other questions, please don't hesitate to ask us.
     

    All the best,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Pawz
    Pawz avatar
    51 posts
    Member since:
    Aug 2007

    Posted 31 Aug 2008 Link to this post

    Ok that works (thanks!) but there's one more thing - how would I get the text to wrap inside the table header?
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 02 Sep 2008 Link to this post

    Hello Pawz,

    Thank you for writing.

    Currently, RadGridView does not support wrapping text in its header cells. We will consider adding this functionality in some of the next releases.

    Currently, you could manually split the header text to couple of rows. Please review the code-block below as reference:
     
    void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) 
        if (e.CellElement is GridHeaderCellElement && e.CellElement.ColumnIndex == 0) 
        { 
            e.CellElement.Text = "First line \nSecond Line"
        } 

    If you need additional assistance, I will glad to help you again.
     

    Greetings,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. KUMARAN
    KUMARAN avatar
    28 posts
    Member since:
    May 2014

    Posted 06 Jan 2015 in reply to Martin Vasilev Link to this post

    How do I set the height of my column headers using Vb.net Coding..That above coding not working with my vb project.
  7. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 06 Jan 2015 Link to this post

    Hi Kumaran,

    Thank you for contacting us. 

    If you want to change the height of header row, you can use the following code snippet: 
    Me.RadGridView1.TableElement.TableHeaderHeight = 50

    You can set the TextWrap property of column`s header cell using this code: 
    Private Sub radGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs)
        If TypeOf e.CellElement Is GridHeaderCellElement AndAlso e.CellElement.ColumnIndex = 1 Then
            e.CellElement.TextWrap = True
        Else
            e.CellElement.ResetValue(LightVisualElement.TextWrapProperty, Telerik.WinControls.ValueResetFlags.Local)
        End If
    End Sub

    I attached a sample demo with version Q3 2014 SP1(2014.3.1202).  

    Hope this will help you. Let me know if you have any another questions.

    Regards,
    Ralitsa
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. KUMARAN
    KUMARAN avatar
    28 posts
    Member since:
    May 2014

    Posted 06 Jan 2015 in reply to Ralitsa Link to this post

    Thanks Ralitsa its working for Gridview,
    but not working with my hierarchical grid 
    I tried with Master template and Child templates .
    Table element doesn't suit for the Master Template.


  9. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 07 Jan 2015 Link to this post

    Hi Kumaran,

    Thank you for your reply. 

    You can use the following code snippet to set the height of a child template: 
    Private Sub radGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs)
        If TypeOf e.CellElement Is GridHeaderCellElement Then
            e.CellElement.TextWrap = True
        Else
            e.CellElement.ResetValue(LightVisualElement.TextWrapProperty, Telerik.WinControls.ValueResetFlags.Local)
        End If
        If TypeOf e.CellElement Is GridDetailViewCellElement Then
            Dim tableElement As GridTableElement = DirectCast(e.CellElement, GridDetailViewCellElement).ChildTableElement
            tableElement.TableHeaderHeight = 100
        End If
    End Sub

    In the attachments you can find a sample demo. 

    Should you have further questions, I would be glad to help.
     
    Regards,
    Ralitsa
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  10. Hugo Furth
    Hugo Furth avatar
    31 posts
    Member since:
    Dec 2008

    Posted 08 Jan 2015 in reply to Martin Vasilev Link to this post

    Trying to follow this but when I open the 'Edit UI' editor, all I see is the RootRadElement (attachement 1). GridTableElement is not in the hierarchy.

    My grid is very simple....just 2 text columns (see attachement 2).

    Any help appreciated.
    Hugo
  11. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 12 Jan 2015 Link to this post

    Hi Hugo,

    Thank you for contacting us. 

    You can not set the TableHeaderHeight property at design time. You need to set it at run time. Please use the following code snippet in the constructor of the form or in the Load event of form: 
    this.radGridView1.TableElement.TableHeaderHeight = 50;

    If you have any additional questions, please let me know.

    Regards,
    Ralitsa
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready