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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ResizeToFit problem with TextRenderer

Thread ID:

Created:

Updated:

Platform:

Replies:

50013 Oct 3,2006 04:11 PM UTC Oct 6,2006 07:25 AM UTC WinForms 4
loading
Tags: GridControl
Francesco Donati
Asked On October 3, 2006 04:11 PM UTC

In the example in attach the fit to header works properly but the fit to content and fit to column do not work (they smaller than they should).

Use the buttons for fitting all the columns or the context menu options for fitting the selected columns.

Where is the bug?

Please let me know.

Thanks
Francesco




ResizeToFitTest.zip

Administrator [Syncfusion]
Replied On October 4, 2006 05:57 AM UTC

Hi Francesco,

In your TextBoxModel class, you need to override CalculatePreferredCellSize, and in your override return the proper size for your cell based on the information passed in. This is the method that grid.Model.ColWidths.ResizeToFit and grid.Model.RowHeights.ResizeToFit calls to get the values it uses to determine the sizes. Below is a code snippet

public override Size CalculatePreferredCellSize(Graphics g, int rowIndex, int colIndex, GridStyleInfo style, GridQueryBounds queryBounds)
{
Size size = g.MeasureString(style.Text,style.GdipFont).ToSize();
return size;
}

Modified sample : http://www.syncfusion.com/Support/user/uploads/ResizeToFitTest_f6d5bbab.zip

Thanks,
Haneef

Francesco Donati
Replied On October 5, 2006 04:27 PM UTC

Thanks, now it works fine.

Another question? If I double click between to header columns the column in the left is resized.
To what size it is resized? Can I customize the double clicking so that it behave like a fit content?

Thanks in advance.
Francesco

Administrator [Syncfusion]
Replied On October 6, 2006 05:06 AM UTC

Hi Francesco,

This is a default behavior of the GridDataBound. Doubleclick would autosize the column (to the width of the content) in a GridDataBoundGrid.

However the ResizingColumns event lets you implement the behavior you want: Here is the code snippet.

private void gridResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if( e.Reason == GridResizeCellsReason.DoubleClick )
{
//Event should be cancelled.
e.Cancel = true;
}
}

Best Regards,
Haneef

Francesco Donati
Replied On October 6, 2006 07:25 AM UTC

Hi Haneef,

How you can see from the example that you send you before the double clicking is not fitting the content correctly.
On the contrary the other fitting commands (with buttons or context menu) work fine.

What is the problem?

Thanks
Francesco

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;