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

How to apply a best fit programmatically for radGridView Winform control ?

8 Answers 711 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tuan Pham
Top achievements
Rank 1
Tuan Pham asked on 27 Apr 2007, 10:05 PM
Please help!
How to apply a best fit programmatically for radGridView Winform control ?

Thanks.

8 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 02 May 2007, 09:45 AM
Hi Tuan Pham,

There is a way to access the "BestFit" method, even though the API is not quite "pleasant". Here is a code snipped that does it:
GridHeaderRowElement headerElement = (GridHeaderRowElement) ((GridTableElement) this.radGridView1.GridElement).TableBodyElement.Children[0]; 
headerElement.BestFitColumn(radGridView1.MasterGridViewTemplate.Columns.FindByDataField("CompanyName") ); 

I also prepared you a sample application that deomnstrates this functionality. Please find it attached.
We are currently enhancing the API, including the one related to this functionality. The more "clear" version will be introduced no later than SP1, that is expected in about three weeks.

Kind regards,
Mike
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Erik
Top achievements
Rank 1
answered on 10 Jul 2007, 05:31 AM
Hi,

Can I have the code in VB.Net?
Thanks
0
Georgi
Telerik team
answered on 12 Jul 2007, 01:02 PM
Hello eriksurya,

Here is attached the same project, converted VB.Net.

If you have any other questions, please do not hesitate to write back.

All the best,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Craig Finnigan
Top achievements
Rank 1
answered on 28 Apr 2009, 07:43 PM
Has a more elegant way of this been released witht he Q1 2009 SP1?
0
Martin Vasilev
Telerik team
answered on 01 May 2009, 11:17 AM
Hello Craig Finnigan,

Thank you for the question.

Yes, currently you can use the GridViewTemplate BestFitColumns method:

this.radGridView1.MasterGridViewTemplate.BestFitColumns(); 

Do not hesitate to contact me again if you have other questions.

Greetings,
Martin Vasilev
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
Kris
Top achievements
Rank 1
answered on 08 Apr 2011, 03:30 AM
Am I missing something here?  I am trying to have all my columns adjust to the best fit and nothing seems to happen.

radGridView1.DataSource = dictionary;
 
radGridView1.MasterTemplate.BestFitColumns();

I am databinding to a list of custom objects.

public class dict
    {
        public string DictionaryCode { get; set; }
        public int AttributeMarkCount { get; set; }
        public string Heading { get; set; }
        public string Structure { get; set; }
        public string Reserve1 { get; set; }
        public string Reserve2 { get; set; }
        public string OutputConversionCode { get; set; }
        public string ProcessingCode { get; set; }
        public string Justification { get; set; }
        public string Width { get; set; }
        public string Reserve3 { get; set; }
        public string Reserve4 { get; set; }
        public string Reserve5 { get; set; }
        public string InputConversionCode { get; set; }
        public string Macro { get; set; }
        public string Reserver6 { get; set; }
    }

  List<dict> dictionary = new List<dict>();
.... Add a bunch of items....

Well it looks like it is working but only when I re size the grid does it draw correctly.

I tried radgridview.Refresh(); but it still only works after a re size.
0
Kris
Top achievements
Rank 1
answered on 08 Apr 2011, 06:06 AM
I figured this out.  Program structure issue.
0
Martin Vasilev
Telerik team
answered on 12 Apr 2011, 12:34 PM
Hello kris munroe,

I am glad you have found a solution for the experienced issue. Let me know if you have any additional questions.

Best wishes,
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
Tags
GridView
Asked by
Tuan Pham
Top achievements
Rank 1
Answers by
Mike
Telerik team
Erik
Top achievements
Rank 1
Georgi
Telerik team
Craig Finnigan
Top achievements
Rank 1
Martin Vasilev
Telerik team
Kris
Top achievements
Rank 1
Share this question
or