I have a windows from with two data grid views. They both have the property AllowUserToResizeColumns = True, one let's me resize the column, the other one not. Any clues?
Printable View
I have a windows from with two data grid views. They both have the property AllowUserToResizeColumns = True, one let's me resize the column, the other one not. Any clues?
Hiya
I had a problem like this, when I set the DataGridView to AutoSizeColumnsMode.AllCells the columns were not resizable, even though I had set the AllowUserToResizeColumns to True. There wasnt much out there about this so i did the following, it aint pretty but it worked for me and hopefully it will help someone else: essentially, you set the AutoSizeColumnsMode mode to AllCells, then measure the width of each column, then set AutoSizeColumnsMode back to None and reset the width of all of the columns.
Code:
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
DataGridView1.AllowUserToResizeColumns = True
DataGridView1.DataSource = oDataSet.Tables(0).DefaultView
Dim IntArray(100) As Integer
Dim i As Integer = 0
Dim oColumn As DataGridViewColumn
For Each oColumn In DataGridView1.Columns
IntArray(i) = oColumn.Width
i = i + 1
Next
i = 0
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None
For Each oColumn In DataGridView1.Columns
oColumn.Width = IntArray(i)
i = i + 1
Next
Why would you autosize the columns at all if you intend to let the user size the columns as they want? The two have different aims.
Excellent solution fatbloke to a problem that still exists 6 years later. :thumb: