-
Oct 13th, 2020, 08:11 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Why disabling DGV Column Sorting, disables DataGridViewAutoSizeColumn mode?
Hello!
I have DGV perfectly fine, it is not bound to anything, populated programmatically, something like this:
Then I needed to disable Column Sorting when I click on any column header, so I inserted this code:
VB.NET Code:
For Each dgvc As DataGridViewColumn In DataGridView1.Columns
dgvc.SortMode = DataGridViewColumnSortMode.NotSortable
Next
Then all the columns in my DGV are not in Autosize mode anymore:
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?
Last edited by Spybot; Oct 13th, 2020 at 08:17 PM.
-
Oct 13th, 2020, 08:27 PM
#2
Re: Why disabling DGV Column Sorting, disables DataGridViewAutoSizeColumn mode?
I see nothing in that screenshot that indicates that the columns aren't auto-sizing anymore.
Now, you might say, "But in the second screenshot, the columns are clearly narrower than in the first screenshot!!!"
To which I would say, yes, but what is probably happening is that, since the columns can no longer be sorted, the "extra width" from the first screenshot that was set aside in each column header to display the little arrow that indicates the column and direction of sorting isn't needed any longer, so each column is "shrunk" by that size.
-
Oct 14th, 2020, 12:20 AM
#3
Thread Starter
Hyperactive Member
Re: Why disabling DGV Column Sorting, disables DataGridViewAutoSizeColumn mode?
OK, so The Autosizemode is still working, it's just that all the columns were shrunk that little arrow on the column headers.
So I guess I'll need to make the column Headers unclickable instead of not sortable.
-
Oct 14th, 2020, 12:29 AM
#4
Re: Why disabling DGV Column Sorting, disables DataGridViewAutoSizeColumn mode?
I think that using Programmatic instead of NotSortable should work. That still leaves space for a sorting glyph but, unless you provide code to do so, will not actually do any sorting or display a glyph.
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
|