ResizeToFit problem with TextRenderer
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
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
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
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
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
FD
Francesco Donati
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
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
AD
Administrator
Syncfusion Team
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
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
FD
Francesco Donati
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
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
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
FD Francesco Donati
- Oct 3, 2006 04:11 PM UTC
- Oct 6, 2006 07:25 AM UTC