-
Dec 29th, 2020, 04:11 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] DataGridView FullRowSelect selects column header too
Hi there,
I've used many DataGridViews and never come across this problem.
When I set the SelectionMode to "FullRowSelect", the full row shows as selected as you'd expect, but the ColumnHeader of the actual Cell clicked also shows as selected.
A solution that stops this happening is to set EnableHeaderVisualStyles to False, but then this removes the highlighting of a Column Header when the cursor hovers over it, which I want.
I've married up the same settings from another project where this isn't happening, and it's still happening.
Any help would be appreciated.
Thank you.
-
Dec 29th, 2020, 10:15 PM
#2
Re: DataGridView FullRowSelect selects column header too
You mean the RowHeader is always selected when the full row is selected? That's the default behaviour for a DGV
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 29th, 2020, 10:27 PM
#3
Re: DataGridView FullRowSelect selects column header too
Looks like you'll have to do some conditional formatting on the fly...
Code:
Private Sub DataGridView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseMove
'The rowheader column's ColumnIndex is -1
Debug.Print(DataGridView1.HitTest(e.X, e.Y).ColumnIndex.ToString)
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 30th, 2020, 11:59 AM
#4
Thread Starter
Hyperactive Member
-
Jan 25th, 2021, 04:48 PM
#5
Thread Starter
Hyperactive Member
Re: DataGridView FullRowSelect selects column header too
Luckily I've managed to find the solution here:
https://stackoverflow.com/questions/...ader-selection
You need to add the following code to the "app.config" file:
xml Code:
<runtime>
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=true" />
</runtime>
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
|