Maybe I am confused. What AutoSize property are we talking about here? And what does it have to do with the VisibleRow?
The only AutoSize property I am aware of is the one on Control, which the grid inherits. But this was added to control in CLR2 and the grid does not support it. Even if it did, it would not affect the columns or rows in the grid, as AutoSize is intended to size the control itself within it's container.
So what exactly are you trying to auto size? You might be looking for AutoFitStyle. Or perhaps the PerformAutoResize method on the columns.
Column AutoSize is not done automatically. This property is for when the user is resizing the column. If you want to fill the whole grid surface you need to use AutoFit:
grid.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns
or:
grid.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn
Hi Stefan,
If the grid is losing it's layout when you call SetDataBinding, it means that the data source you are binding to does not match the schema you set up at design-time in some way.
Perhaps one of the band or column keys does not match up.
Personally, I find it much easier to set up the layout of my grid using the InitializeLayout event, rather than the designer. The VS form designer tends to be a bit flaky when dealing with data source notifications and can sometimes cause the layout to be reset when it doesn't seem to need to.