|
-
Dec 5th, 2007, 08:49 AM
#1
Thread Starter
Fanatic Member
[2005] DataGridView - AllowUserToResizeColumns property
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?
-
Feb 12th, 2008, 06:52 AM
#2
Junior Member
Re: [2005] DataGridView - AllowUserToResizeColumns property
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
-
Feb 12th, 2008, 07:03 AM
#3
Re: [2005] DataGridView - AllowUserToResizeColumns property
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.
-
Apr 15th, 2016, 11:46 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|