DataGridView auto size columns without showing the grid
I need to get DataGridView column sizes without showing the the grid (for printing). I'm using data binding through DataSource (using BindingSource doesn't seem to work too).
For whatever reason I get wrong column sizes. If I show t开发者_如何学Gohe grid in a form first, everything is fine. If I try to get column sizes after setting no DataSource and executing AutoResizeColumns(), columns are too wide (didn't autosize).
How can I force grid to do it's job without showing it?
Fixed. Use CreateControl() to initialize control, binding, handle, etc.
精彩评论