DataGridView - user sizing columns

  • Thread starter Thread starter proxyuser
  • Start date Start date
P

proxyuser

I have AllowUserToResizeColumns = true. AutoSizeColumnsMode is set to
AllCells. When the grid is displayed with data, the columns are not
resizable with the mouse. Any ideas?
 
I have AllowUserToResizeColumns = true. AutoSizeColumnsMode is set to
AllCells. When the grid is displayed with data, the columns are not
resizable with the mouse. Any ideas?

If you set AutoSizeColumnsMode to AllCells, then each cell will always
be the width necessary to display and it makes no sense to allow the
user to resize the columns since they are constrained to be a fixed
size.

It depends what you want to do. I suppose you want the grid columns
to initially be sized to exactly fit the data, but then allow the user
to later change it.

What I usually do is to set the columns that are relatively narrow to
AllCells, and the larger ones to size to a percentage of the remaining
space, which allows the user to change those columns.
 
Jack Jackson said:
It depends what you want to do. I suppose you want the grid columns
to initially be sized to exactly fit the data, but then allow the user
to later change it.

Exactly. I didn't know AllCells constrained it.
What I usually do is to set the columns that are relatively narrow to
AllCells, and the larger ones to size to a percentage of the remaining
space, which allows the user to change those columns.

The grid is showing dynamic data, and I don't know that columns or sizes at
dev time. Also, we'll be virtualizing it, so I don't really want to waste
much run time calculating all the column data widths.
 
Exactly. I didn't know AllCells constrained it.


The grid is showing dynamic data, and I don't know that columns or sizes at
dev time. Also, we'll be virtualizing it, so I don't really want to waste
much run time calculating all the column data widths.

Then I wouldn't autosize to the size of the current data. Instead I
would make a guess as to which columns need to be wider than others
and set each to a proportion of the grid width.
 
Back
Top