Hi. I'm trying to do something really, really simple, and failing utterly:
I want my grid colums to resize as if I'd manually clicked on each columns separator in the heading, so that they will resize to the largest data (or if the text in the heading is wider, to the heading text) in that column.
I have tried this:
Me.grd_Sales.DisplayLayout.Bands(0).Columns(crtr).PerformAutoResize()
Next crtr
But it does not work as I interpret the intellisense help, on a non-overloaded option Instead, it resizes to the width of the text in the header - not to the max width of all data in all rows, nor to the max width of the data in visible rows.
I know this should be a no-brainer, but it aint. If I set up a data schema and then go into the layout screen, I can 'hardcode' some widths, but optimally, I'd like a resize to work the way it works in the stock vb grid control.
Thanks.
You are using the wrong overload of PerformAutoResize. The parameterless overload only sizes based on the visible rows. You are probably calling ths before the grid has painted and there are therefore no visible rows. Try PerformAutoResize(AllRowsInBand).