How to wrap text only in Header cell ?

5 posts, 0 answers
  1. Marcin
    Marcin avatar
    1 posts
    Member since:
    Jul 2010

    Posted 12 Jul 2010 Link to this post

    Hello,
    how i can wrap text only for header text ?

     foreach (Telerik.WinControls.UI.GridViewDataColumn items in radGridView.Columns)       
     {             
        items.WrapText = true;
     }


    I use this kind of solve but every cell are wraping.

    And how i can check what kind of data (date, bool, number) in colums... ?
    Thanks for help (my controls Q1 2010 SP2)
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 15 Jul 2010 Link to this post

    Hello Marcin,

    Thank you for writing.

    You can wrap the text of the header row by handling the ViewCellFormatting event. Please consider the following code snippet:
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        if (e.CellElement is GridHeaderCellElement)
        {
            e.CellElement.TextWrap = true;
        }
    }

    I hope this helps. Let me know if you have any other questions.

    All the best,
    Martin Vasilev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ken
    Ken avatar
    2 posts
    Member since:
    Apr 2009

    Posted 19 Sep 2011 Link to this post

    Is there somewhere I can now calculate the required height for the header?  I don't want to set the whole grid to automatic row height, just the header.  I would also need to trap required height changes when the user resizes columns and causes a header to wrap or unwrap.

    Thanks
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 22 Sep 2011 Link to this post

    Hello Ken,

    Thank you for writing.

    RadGridView does not support setting auto size only to the header row. However, you can work-around this limitation by setting AutoSize property to true and choose a fixed value for MinHeight and MaxHeight of every data row as demonstrated below:
    public Form1()
    {
        InitializeComponent();
     
        this.radGridView1.AutoSizeRows = true;
     
        this.radGridView1.RowFormatting += new RowFormattingEventHandler(radGridView1_RowFormatting);           
    }
     
    void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
    {
        e.RowElement.RowInfo.MaxHeight = e.RowElement.RowInfo.MinHeight = 25;
    }

    Hope this helps. Let me know if you have any other questions.

    All the best,
    Martin Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Sree
    Sree avatar
    30 posts
    Member since:
    Dec 2012

    Posted 02 Jan 2013 Link to this post

    Thanks it working perfect :)
Back to Top
UI for WinForms is Visual Studio 2017 Ready