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

resizing the grid

Thread ID:

Created:

Updated:

Platform:

Replies:

63028 Jun 27,2007 03:31 AM Jun 28,2007 06:12 PM Windows Forms 3
loading
Tags: GridControl
Vicko Hazdovac
Asked On June 27, 2007 03:31 AM

Hi... I need a little help with the auto resizing the GridGroupingControl

It seems that the control resizes itself only the first time I use the ResizeToFit method, and every other time it just stays the same.

I'm not sure what I'm doing wrong, so I've attached a simple example of the form.

Please modify it so the grid would resize itself every time. I need it to resize to the biggest cell in the column.
What I mean is: If I enter a text larger than any of the others, the column must fit to that text. Otherwise resize it to the next biggest cell.

Thanks in advance
Vicko

Resze.zip

Jeba S [Syncfusion]
Replied On June 27, 2007 07:55 AM

Hi Vicko,

Thank you for your sample.

Reason:
You try to set the short and long value in the second column(Col 2) but, in GridRangeInfo the column you are passing is the first one(Col 1).

Please refer this modified code and let us know if this helps.

private void button1_Click(object sender, EventArgs e)
{
gridGroupingControl1.Table.Records[0].SetValue("Col 2", "Text");
//Old code
gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(1), GridResizeToFitOptions.None | GridResizeToFitOptions.IncludeHeaders);
//New code
gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(2), GridResizeToFitOptions.None | GridResizeToFitOptions.IncludeHeaders);
}
private void button2_Click(object sender, EventArgs e)
{
gridGroupingControl1.Table.Records[0].SetValue("Col 2", "Looooooooooooooooooooooooooooooooooooooong text");
//Old code
gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(1), GridResizeToFitOptions.None | GridResizeToFitOptions.IncludeHeaders);
//New code
gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(2), GridResizeToFitOptions.None | GridResizeToFitOptions.IncludeHeaders);
}


Best Regards,
Jeba.

Vicko Hazdovac
Replied On June 28, 2007 02:57 AM

This does the exact same thing as before.

The column expands itself if the long text is entered, but if I set the text to back short it doesn't shrink to the next longest text.

(if I enter "Loooooooooong text" column should grow, but if I enter "Text" the column should shrink to "Some text")

How can I achieve this?

haneefm [Syncfusion]
Replied On June 28, 2007 06:12 PM

Hi Vicko,

You can try this code in button1's Click event.

gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Cells(5, 2, gridGroupingControl1.TableModel.RowCount , 2), GridResizeToFitOptions.ResizeCoveredCells);

Best 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

;