I'm trying to auto resize the height of the column header in a bound grid where I'm specifying the column widths and things seem not to be working as I'd anticipated.
I'm using the following code to attempt my resize. It has no effect.
this.MyGrid.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(0));
I've also tried including various GridResizeToFitOptions with no success.
Curiously when I explicitly define the row height using the following code things work fine.
this.MyGrid.Model.RowHeights[0] = 50;
Any assistance would be most gratefully recieved.
Many thanks,
Rob Hughes
AD
Administrator
Syncfusion Team
May 19, 2003 12:59 PM UTC
> I'm trying to auto resize the height of the column header in a bound grid where I'm specifying the column widths and things seem not to be working as I'd anticipated.
>
> I'm using the following code to attempt my resize. It has no effect.
> this.MyGrid.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(0));
>
> I've also tried including various GridResizeToFitOptions with no success.
>
> Curiously when I explicitly define the row height using the following code things work fine.
> this.MyGrid.Model.RowHeights[0] = 50;
>
> Any assistance would be most gratefully recieved.
>
> Many thanks,
> Rob Hughes
You do need to include the IncludeHeaders option. Also, you should turn off the AllowResizeToFit so that does not affect things.
this.gridDataBoundGrid1.AllowResizeToFit = false;
this.gridDataBoundGrid1.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.IncludeHeaders);
RH
Robert Hughes
May 21, 2003 08:13 AM UTC
Thanks Clay.
Unfortunately though this doesn't seem to be working for me. Could there be anything else which is preventing this from happening ? (I didn't mention originally but this grid is bound and within a navigator control.)
As mentioned though, if I replace this auto-resize code with an explicit sizing it does take effect, however the auto-resizing itself in the same code position seems to have no effect.
To check that no code is resetting this sizing for debugging purposes I've put a button on my form which calls the two suggested lines of code. This also has no effect.
Any further suggestions would be very welcome.
Many thanks,
Rob
AD
Administrator
Syncfusion Team
May 21, 2003 09:28 AM UTC
Are you handling any events that might affect colwidths such as QueryColWidth?
What version of the grid are you using? The latest public release is 1.5.2.0 which is available from your support home page on our website. (Not available to eval copies.)
If you can post a sample here showing teh problem, we can look into it. Or, you can also create a Direct Trac support incident and submit a sample there is you would like.
AD
Administrator
Syncfusion Team
May 21, 2003 09:34 AM UTC
Sorry, should have asked about QueryRowHeights, not col widths.
Attached is a little sample that seems to work as expected for me. Does it not work for you?
RH
Robert Hughes
May 22, 2003 11:11 AM UTC
Thanks once again Clay. I'm unable to download your code due to restrictions at the site I'm working at but will do so when I'm home.
Just for the record though I am using version 1.5.2.0.
Also, and I don't know why I hadn't stumbled across this before, if I replace the line
this.MyGrid.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(0))
with
this.MyGrid.Model.Rows.Size.ResizeToFit(GridRangeInfo.Row(0))
then I manage to achieve what I'm after. So ultimately my problem is resolved. I'm still curious though why the former doesn't work but the latter does.
Thanks once again for your help.
Rob
RH
Robert Hughes
May 22, 2003 01:26 PM UTC
Can I withdraw that last statement please ?
I thought things had been resolved but apparently not.
My grid is being used in a generic results screen of an SQL generator. In certain instances the resize works but not in others. Most bizarre, considering the fact that the same grid definition code is being run at all times.
At no point am I handling any grid display events except for the Resize which does the following
this.MyGrid.BeginUpdate();
this.MyGrid.Refresh();
this.MyGrid.EndUpdate();
to repaint.
Any thoughts ?
Thanks
Rob