Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15628

VS 2019 Why disabling DGV Column Sorting, disables DataGridViewAutoSizeColumn mode?

$
0
0
Hello!

I have DGV perfectly fine, it is not bound to anything, populated programmatically, something like this:
Name:  01.jpg
Views: 22
Size:  26.4 KB

Then I needed to disable Column Sorting when I click on any column header, so I inserted this code:
VB.NET Code:
  1. For Each dgvc As DataGridViewColumn In DataGridView1.Columns
  2.             dgvc.SortMode = DataGridViewColumnSortMode.NotSortable
  3.         Next

Then all the columns in my DGV are not in Autosize mode anymore:
Name:  02.jpg
Views: 21
Size:  26.5 KB

The column sorting functionality is working fine now, but my Columns are not in Autosize mode anymore.

Is it possible to have both functionalities working?
Attached Images
  

Viewing all articles
Browse latest Browse all 15628

Trending Articles