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

How to wrap text only in Header cell ?

4 Answers 623 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Marcin asked on 12 Jul 2010, 09:35 AM
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)

4 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 15 Jul 2010, 01:13 PM
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
0
Ken
Top achievements
Rank 1
answered on 19 Sep 2011, 02:36 PM
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
0
Martin Vasilev
Telerik team
answered on 22 Sep 2011, 08:45 AM
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 >>

0
Sree
Top achievements
Rank 1
answered on 03 Jan 2013, 01:38 AM
Thanks it working perfect :)
Tags
GridView
Asked by
Marcin
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Ken
Top achievements
Rank 1
Sree
Top achievements
Rank 1
Share this question
or