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

Best Fit each gridview column based on the record stored

1 Answer 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Faheem Nadeem
Top achievements
Rank 1
Faheem Nadeem asked on 20 Aug 2009, 04:38 AM
Hi,
I have been facing problems adjusting the column length to best fit based on the maximum data present in any of the columns field.
i.e.
the column should automatically maximize to the maximum length of the records in that column
Can you please Help me out, as currently all of my columns are compressed and i have to manually expand each column to have a look at my data.

Note: My gridview is being populated by list using the (datasource) property.

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 20 Aug 2009, 08:19 AM
Hello Faheem Nadeem,

You can achieve this by calling BestFit() method of RadGridView Columns. Here is how you can do it:

foreach (GridViewDataColumn col in this.radGridView1.Columns)  
{  
    col.BestFit();  

Write again if you have other questions.

Kind regards,
Victor
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.
Tags
GridView
Asked by
Faheem Nadeem
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or