We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Derived cell control - auto expand the column width to fit control

Thread ID:

Created:

Updated:

Platform:

Replies:

45444 Jun 21,2006 11:11 AM UTC Jun 22,2006 08:14 AM UTC WinForms 2
loading
Tags: GridControl
Colin Bolton
Asked On June 21, 2006 11:11 AM UTC

I have a custom cell type(implementing a GridGenericControlCellModel as in the calendar example) which contains a control whose size may change dynamically. Is there a simple way to automatically expand the width of the column to fit the size of the control if it is too small? Also if the user changes the column width I want to restrict the width to the size of the largest control in the column, is there a simple way (property to set?) or do I have to handle the column resizing events manually?? Cheers, Colin

Administrator [Syncfusion]
Replied On June 21, 2006 05:25 PM UTC

Hi Colin, Regarding the Question 1: To resize the width of the column to fit the size of the control , you need to call the ResizeToFit method . Here is a code snippet. gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Cell(2, 4)); gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cell(2, 4)); Note : this method only applicable for usercontrol celltype. If the celltype is control cell type , you need to caluclate the width of the control and assign the colWidth explictly. Regardig the Question 2: You need to handle the ResizingColumns event for preventing the resizing of the column in a grid. Here is a code snippet. private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e) { if(e.Columns.Left == 2) e.Cancel = true; } Let me know if this helps. Best Regards, Haneef

Colin Bolton
Replied On June 22, 2006 08:14 AM UTC

Thanks Haneef, I think this does the job.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;