ResizeToFit and QueryCellStyleInfo Event

I use the QueryCellStyleInfo event in my gridgroupingcontrol to show an icon in a column (which depends on another column). Everything seems fine, but the resizetofit function doesn''t seem to work anymore. Cell content is cut (or hidden) by neighbor cells and so on. When I remove the QueryCellStyleInfo event the ResizeToFit works as expected. Isn''t it possible to use both things together (QueryCellStyleInfo and ResizeToFit)? Cheers, Markus

4 Replies

AD Administrator Syncfusion Team September 6, 2005 03:57 PM UTC

Something to try. In QueryCellStyleInfo, try also setting e.Style.TextMagin.Left to reserve the space used by the icon when it is present. This may allow ResizeToFit to work properly.


AD Administrator Syncfusion Team September 7, 2005 07:11 AM UTC

Hmm Clay, I played around with your suggested property - but it doesn''t really do what I want. I have attached an example where you can see that the resize doesn''t really work as expected. GGC_4tables_Resize_8690.zip Perhaps you know what''s wrong? Cheers, Markus


AD Administrator Syncfusion Team September 7, 2005 07:47 AM UTC

A couple of things not as needed here. One is that you subscribe to the QueryCellStyleInfo event after you have called ResizeToFit so there would be no way for the grid to know that it needed to adjust for a bitmap in the resizetofit call. But even subscribing to the event before calling resizetofit is not sufficient as the GridRangeInfo.Table will only catch the visible rows. So, as long as the node is collapsed, it will not really use teh QueryCellStyleInfo event which is what is needed to know about teh image. One solution is to call resizetofit as you expand a node. You could always do it, or you could keep track of what tables have already been sized, and only do it on the first expansion.
void gridGroupingControl1_GroupExpanded(object sender, GroupEventArgs e)
{
	GridTableModel model = gridGroupingControl1.GetTableModel(e.Group.Records[0].ParentTableDescriptor.Name);
	model.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders | GridResizeToFitOptions.IncludeCellsWithinCoveredRange);
}


AD Administrator Syncfusion Team September 7, 2005 08:20 AM UTC

Thanks Clay now it works great !!

Loader.
Up arrow icon