Hi,how can I configure the columns of a grid (5 columns), that only column 3 and 5 take rest of the space inside the grid, but column 1, 2 and 4 are autosized by content?
Michael
Hi Michael,
I think what you can do is set AutoFitStyle to size all of the columns. Then in the InitializeLayout event, call PerformAutoResize on columns 1, 2, and 4. Then set the MinWidth and MaxWidth on those columns to their current (autosized) width. This way, those columns will be sized to their content and locked in place and the other columns will be the only sizeable ones.
It sounds like a workaround, but the user can't resize the other columns (1, 2, 4).
These columns (1, 2, 4) should not effected by any risizing of the grid. But the user should have the ability to resize them.
Hmm... I can't see any obvious way to do that. Perhaps if you can set the MinWidth and MaxWidth in the InitializeLayout as I suggested, then trap the Paint event of the form or the grid and after the first time it paint, reset these properties back to their defaults. You would need a flag to make sure this only happens the first time Paint fires. Presumably, the columns will have been resized after the first paint, so that seems like it should work theoretically. I haven't tried it, though.