I have a DataGridView with a DataSource and I want the data to be displayed on the entire width of the control with the auto-computed width of each column. The exception is the first one which should always have 100px.
I handled the Size event, I set always the fist column to have 100px and it works, but only if I manually resize the grid.
Is there any way I can do this automatically, right after the DataSource was set?
I tried to invalidate the control, I set (again) the autofill (and not only) flags of the grid, but no luck. Did anyone managed to do a similar thing?
When editing the columns, there is a property called AutoSizeMode
. Im wondering why you are trying to handle it yourself. Just set all columns except the first one to AutoSizeMode = AllCells
and then give your first column the width of 100px. Should do it shouldnt it?
Bonus: You can even set one of the columns to Fill
in AutoSizeMode
. Would look a bit better as your table is taking the full width.
If I missed the point please correct me...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.