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. Image for the cookie policy date

resizetofit virtual grid

Hi

How to handle the ResizeToFit before the queryCellInfo is raised?

There is any event after the queryCellInfo is raised, and before the grid is shown, we can call ResizeToFit to set the column width based on the first 10 rows data?

Thanks
Hui

7 Replies

AD Administrator Syncfusion Team September 13, 2006 05:18 AM UTC

Hi Hui,

I have created the sample as per your requirement. The Attached will helps you to resize the column by using ResizeToFit method in the virtual grid and let me know if you are looking something different.

this.gridControl1.ResetVolaititeData();
this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Row(10),GridResizeToFitOptions.None);

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/VirtualGridResizing_b1a942bd.zip

Let me know if this helps.

Best Regards,
Haneef


HZ Hui Zhong September 13, 2006 04:50 PM UTC


Thanks.

However, my scenario is little complicated that the example you linked.

For some reason, in my scenario, though call the function ResetVolatileData() will not querycellinfo to paint the cellvalue from its view data behind. That''s the reason why ResizeToFit is not working because the cellValue ="".

Is there event or functions I can call before I call ResizeToFit?

Thanks
Hui
>Hi Hui,

I have created the sample as per your requirement. The Attached will helps you to resize the column by using ResizeToFit method in the virtual grid and let me know if you are looking something different.

this.gridControl1.ResetVolaititeData();
this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Row(10),GridResizeToFitOptions.None);

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/VirtualGridResizing_b1a942bd.zip

Let me know if this helps.

Best Regards,
Haneef


HZ Hui Zhong September 19, 2006 01:23 AM UTC

Hi
Can I get answer from this following question?

Regards,
Hui

>Hi

How to handle the ResizeToFit before the queryCellInfo is raised?

There is any event after the queryCellInfo is raised, and before the grid is shown, we can call ResizeToFit to set the column width based on the first 10 rows data?

Thanks
Hui


AD Administrator Syncfusion Team September 19, 2006 08:28 AM UTC

Hi Hui,

Sorry for the delay in getting back to you.

You can handle the QueryColWidth event and set the width of the column in a Grid. Below is a code snippet.

this.grid.QueryColWidth +=new GridRowColSizeEventHandler(gridQueryColWidth);

private void gridQueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if(e.Index%2 == 0 )
{
e.Size = 100;
e.Handled = true;
}
}

Thanks,
Haneef


HZ Hui Zhong September 19, 2006 06:33 PM UTC

Haneef,

Thanks for your response.
However, I need to use the ResizeToFit to get the column width, instead of using fixed width like 100 in your example. As I know, call ResizeToFitin queryColwidth event will cause StakeOverFlowException.

Regards,
Hui

>Hi Hui,

Sorry for the delay in getting back to you.

You can handle the QueryColWidth event and set the width of the column in a Grid. Below is a code snippet.

this.grid.QueryColWidth +=new GridRowColSizeEventHandler(gridQueryColWidth);

private void gridQueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if(e.Index%2 == 0 )
{
e.Size = 100;
e.Handled = true;
}
}

Thanks,
Haneef


HZ Hui Zhong September 22, 2006 08:02 PM UTC


Haneef,

Could you please give me a response on it. Thanks.

Hui
>Haneef,

Thanks for your response.
However, I need to use the ResizeToFit to get the column width, instead of using fixed width like 100 in your example. As I know, call ResizeToFitin queryColwidth event will cause StakeOverFlowException.

Regards,
Hui

>Hi Hui,

Sorry for the delay in getting back to you.

You can handle the QueryColWidth event and set the width of the column in a Grid. Below is a code snippet.

this.grid.QueryColWidth +=new GridRowColSizeEventHandler(gridQueryColWidth);

private void gridQueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if(e.Index%2 == 0 )
{
e.Size = 100;
e.Handled = true;
}
}

Thanks,
Haneef


AD Administrator Syncfusion Team September 25, 2006 05:11 AM UTC

Hi Hui,

Sorry for the delay in getting back to you.

The reason is that you are calling the ResizeToFit method in QueryColWidth event. The ResizeToFit will fire QueryRowHeight / QueryColWidth to get the current height / width.

You should call the resizeToFit after the data has changed. So when you change your underlying data, call ResizeToFit at that point. The resize method will automatically receive the new data when the method requests the data from the grid. Here is a little sample. It is a virtual grid that has button to resize particular pieces of the grid. If you change the text in those pieces and click the button, the cells are resized as needed. There is also a button that bolds the font in those areas of the grid (you have to do this dynamcailly from within QueryCellInfo). If you click the bold button, it will bold the font and resize the cell.

Thanks for your patience.

Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon