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

AutoSizeRows and Row MinHeight terrible issue.

11 Answers 449 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 09 Dec 2009, 01:20 PM
hi Guys,

Sorry i m quite new to the Telerik RadControls.
I have a terrible issue with the autosize property of the RadGridview for winforms.

I set my AutoSizeRows to True at design time and autosize columns mode = none.

then in  my code..
MYGridView.DataSource = dataSet.Tables[0].DefaultView;
MYGridView.Columns["Comments"].MaxWidth = 500;
MYGridView.Columns["Comments"].WrapText = true;
    foreach (Telerik.WinControls.UI.GridViewDataColumn item in MYGridView.Columns)
                    {
                        item.BestFit();
                    }
And after this. i when i look at my girdview its autosized its contents to the size of of the font in the cells. which is very very ugly.
i want to set a minHeight for the columns but i am unable to do so.. please help...

i have tried what is discussed in these threads but of now use.

http://www.telerik.com/community/forums/winforms/gridview/wraptext-and-autosizerows-true.aspx
http://www.telerik.com/community/forums/winforms/gridview/wrapping-text-in-cell.aspx

Please give me your valuable suggestions.

Thanks in advance.



11 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 10 Dec 2009, 10:24 AM
Hi Joe,

Did you try setting a padding? The following code should work:

void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    e.CellElement.Padding = new Padding(5);
}

RadGridView uses virtualization for its rows and it creates visual row elements only for rows that are currently visible on screen. Then these elements are reused upon scrolling. CreateRow event fires when visual rows are created. That's why you can't change the MinHeight property in this event. However, you can iterate all rows after binding the grid:

this.radGridView1.DataSource = table;
for (int i = 0; i < this.radGridView1.Rows.Count; i++)
{
    this.radGridView1.Rows[i].MinHeight = 50;
}
this.radGridView1.AutoSizeRows = true;

I hope this helps.
 
Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Joe
Top achievements
Rank 1
answered on 10 Dec 2009, 12:23 PM
hi Jack,
Thanks for your reply.
It has helped me fix my grid rows except the header. when i set the padding its hiding the headetext since its small in size for padding 5.
so i managed to put a condition for the headerrow for today..
if (e.CellElement is GridHeaderCellElement)
            {
                ((GridViewTableHeaderRowInfo)e.CellElement.RowInfo).MinHeight = 80;
            }
            else
            {
                e.CellElement.Padding = new Padding(5);
            }
but it will be great if you could help me fix the problem with my header row size.
thanks in advance.
Joe.


0
Accepted
Jack
Telerik team
answered on 11 Dec 2009, 08:57 AM
Hello Joe,

Could you please specify the version of RadControls that you are using. I cannot reproduce the issue using our latest release - Q3 2009 SP1. I recommend that you try this version. We will appreciate your feedback.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Joe
Top achievements
Rank 1
answered on 19 Jan 2010, 08:43 AM
HI Jack

i have managed to update the my version to Q3 2009 SP1 and issues seems to disappear.

thought i had a bad time upgrading my entire solution to the latest version, due to nasty problems with RadTextBox with multiline and with BubbleBar Controls.

thanks

Joe
0
Jack
Telerik team
answered on 19 Jan 2010, 10:32 AM
Hello Joe,

I am glad to hear that. If you experience any other issue or you have question, please contact me back.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mathieu Yargeau
Top achievements
Rank 1
answered on 26 Mar 2010, 03:54 PM
I have a problem with the AutoSizeRows, my headers height do not change after the initial loading.

 

I want only my header to be AutoSize, so each row has MinHeight and MaxHeight = 20 (I only add rows with programmation, I set thos values when I add the row). I don't touch the MinHeight and MaxHeight of the header, but I set the height to 20. When the grid loads, the header text is set. After, I set AutoSizeRows = true.

WrapText = true. If I resize a column, nothing changes. If I resize every column so that they are very large (so need less height), nothing changes. Same thing if I resize the columns so that they need a very high header. Same thing if I change the header text of every column.

 

 

0
Svett
Telerik team
answered on 29 Mar 2010, 02:32 PM
Hi Mathieu Yargeau,

You should set the TextWrap property of the cells in your header. You should subscribe for the ViewCellFormatting event where you can manipulate all kind of cells. You can use the following code snippet:

private void radGridView_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.RowInfo is GridViewTableHeaderRowInfo)
    {
        e.CellElement.TextWrap = true;
    }
}

In case of that the supplied solution didn't resolve the issue, can you send us a sample project and describe what you desire to achieve? You can do so in a new support ticket.

If you need further assistance feel free to write us back.

Greetings,
Svett
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
Mathieu Yargeau
Top achievements
Rank 1
answered on 29 Mar 2010, 02:45 PM
The CellElement does not have a TextWrap property.

I'm using the WinForms 2009 Q3 1203 version.
0
Svett
Telerik team
answered on 01 Apr 2010, 10:04 AM
Hi Mathieu Yargeau,

My previous code snippet is related to Q1 2010. In version Q3 2009 v2009.3.9.1203 there is a issue regarding text wrapping. So, I would suggest that you update to Q1 2010 as it contains many new features and improvements. Then you can apply the code snippet.

If you need further assistance, feel free to write us back.

Greetings,
Svett
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
Mathieu Yargeau
Top achievements
Rank 1
answered on 06 Apr 2010, 04:42 PM
I just upgraded to the Q1 2010 version and tried your solution. The TextWrap works, but the header's height does not change when I resize the column's width small enough to activate the TextWrap, even if AutoSizeRows is True.

If I had to create a sample, there would only be the code snippet you gave me in it, plus the AutoSizeRows = True.

I created a project with only that and the problem is still there.
0
Svett
Telerik team
answered on 09 Apr 2010, 09:44 AM
Hello Mathieu Yargeau,

This is a know issue. I cannot give you a temporary solution due to some internal methods and fields that should be changed. The issue will be addressed in the upcoming service pack, which will be published next week.

If you have further questions do not hesitate to write us back.

Best wishes,
Svett
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.
Tags
GridView
Asked by
Joe
Top achievements
Rank 1
Answers by
Jack
Telerik team
Joe
Top achievements
Rank 1
Mathieu Yargeau
Top achievements
Rank 1
Svett
Telerik team
Share this question
or