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

resizetofit virtual grid

Thread ID:

Created:

Updated:

Platform:

Replies:

49183 Sep 12,2006 09:08 PM UTC Sep 25,2006 05:11 AM UTC Windows Forms 7
loading
Tags: GridControl
Hui Zhong
Asked On September 12, 2006 09:08 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Hui Zhong
Replied On 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

Hui Zhong
Replied On 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

Administrator [Syncfusion]
Replied On 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

Hui Zhong
Replied On 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

Hui Zhong
Replied On 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

Administrator [Syncfusion]
Replied On 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

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

;