GridView Column Header Wrap Text

6 posts, 0 answers
  1. Sree
    Sree avatar
    30 posts
    Member since:
    Dec 2012

    Posted 27 Dec 2012 Link to this post

    Hello Telerik Team,
    i am developing a solution in which user adds his defined columns to the gridview and the number of columns not limited to some number, there may be 'n' number of columns, my question is when user gives a very long text for the header , i want to wrap the text to some confined width in the header
    i wonder there is no vertical stretch to header ,i tried bestFit, autosize everything but unable to find the answer


    i want to wrap the header text something like below, is this possible ?????


    can you please help me out
  2. Anton
    Admin
    Anton avatar
    167 posts

    Posted 02 Jan 2013 Link to this post

    Hello Lakshmi,

    Thank you for writing.

    You can achieve the desired behavior through subscribing to the ViewCellFromating event of the RadGridView and setting the TextWrap property to true. For example:
        this.radGridView1.ViewCellFormatting += new Telerik.WinControls.UI.CellFormattingEventHandler(radGridView1_ViewCellFormatting);
      
     
    void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
    {
        if (e.CellElement is GridHeaderCellElement)
        {
            e.CellElement.TextWrap = true;
        }
    }

    This topic is also discussed in the following forum thread: http://www.telerik.com/community/forums/winforms/gridview/how-to-wrap-text-only-in-header-cell.aspx

    I hope this helps. If you have further questions, feel free to write back.

    Regards,
    Anton
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sree
    Sree avatar
    30 posts
    Member since:
    Dec 2012

    Posted 02 Jan 2013 Link to this post

    Hello Team,
    thanks it working perfect :)
  5. RIZAL
    RIZAL avatar
    11 posts
    Member since:
    Jun 2015

    Posted 23 Feb Link to this post

    Hi, is this code is still relevant for release 2016.1.216.40?

    How to proceed in vb code?

    Thank you.

  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 24 Feb Link to this post

    Hello Rizal,

    Thank you for writing.
     
    The code snippet is still applicable for the latest version. Here is the snippet in VB:
    Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _
        Handles RadGridView1.ViewCellFormatting
        If TypeOf e.CellElement Is GridHeaderCellElement Then
            e.CellElement.TextWrap = True
        End If
    End Sub

    Feel free to use our online converter from C# to VB.NET and vice versa: http://converter.telerik.com/

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. RIZAL
    RIZAL avatar
    11 posts
    Member since:
    Jun 2015

    Posted 24 Feb in reply to Dess Link to this post

    Hi Dess,

    Thank you, it works perfectly.

Back to Top
UI for WinForms is Visual Studio 2017 Ready