I have a datagridview that is populated and added to the winform programmatically.
The number of columns within the gridview can vary greatly, so I want to change the size of the actual Gridview width to fit the number of columns.
Could anybody suggest how to do this?
Thanks.
Maybe I didn’t understand it, but can’t you just modify the width property of the grid each time you add a column?
EDIT:
Ok, so you add the columns binding it to a datasource. But later, you con do something like:
Other solution could be redraw you form, and put the grid inside a panel, and set the dock property of the grid to Fill. The grid will use all the space available, and if more is needed, then will show scroll bars.