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

Header row height problem

3 Answers 456 Views
GridView
This is a migrated thread and some comments may be shown as answers.
TechManagers
Top achievements
Rank 1
TechManagers asked on 17 Jun 2009, 08:49 PM
I cannot seem to keep the header row from auto-sizing its height.

What is the property that needs to be set to keep the header row height static and just use elipses if the text is too long?

3 Answers, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 19 Jun 2009, 12:50 PM
Hi Tom Ottman,

Thank you for contacting us.

As far as I understand you are using a RadGridView and you have set the AutoSizeRows property to true. You have also enabled the WrapText functionality of the columns. So, your issue is that you would like to avoid AutoSizing and TextWrapping in the header cells. You want the HeaderRow to have static size and you do not want the text to be wrapped.
 
If this is your case, please have a look at the attached file. The project I have prepared demonstrates how you can achieve this behavior. First, you have to create a class that  inherits from GridTableHeaderRowElement  and override the MeasureOverride() method. Further, you need to subscribe to the CreatRow() event and make changes only to rows that are of type GridTableHeaderRowElement. One more detail, if you want to use themes, you have to customize the xml file. I have modified the default theme for you. The new theme name is VistaModified. Please, contact us back if you are using another theme.

Please, let me know if this is helpful. I am looking forward to your reply.

Regards,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Vivek
Top achievements
Rank 1
answered on 01 Feb 2011, 06:53 PM
I have the exact same problem.
I want the header height to be constant in the UI and I want to set AutoSizeRows = true for the data rows. 
When I set  AutoSizeRows = true it resizes the header as well as the data rows.
to get around it I created a custom class 

class B9DataGridViewColumnHeader : GridTableHeaderRowElement
    {
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF size = base.MeasureOverride(availableSize);
            size.Height = 30;
            return size;
        }
    }

Overrode the CreateRow for DataGridView as suggested. This results in a grid with with empty space at top left/ See attached snapshot.




0
Stefan
Telerik team
answered on 04 Feb 2011, 02:16 PM
Hi Vivek,

Thank you for writing.

You can set the size of the header row by using the following code snippet:
radGridView1.MasterView.TableHeaderRow.MinHeight = 24;

This will set its size and it will not be affected by the AutoSize functionality.

I hope this helps. Let me know if you need anything else.
 
Kind regards,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
TechManagers
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Vivek
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or