Results 1 to 5 of 5

Thread: [RESOLVED] DataGridView FullRowSelect selects column header too

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    Resolved [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.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    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

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    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

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    Re: DataGridView FullRowSelect selects column header too

    Paul,

    Thank you for your response.

    No I meant as I wrote the Column Header appears selected.

    Please see attached images showing the cell I click (see mouse cursor), the Row shows as selected, but also the corresponding column header does.

    The final image shows the header highlight on hover, I would like to retain this functionality.

    Thank you.

    Name:  dgv-header1.jpg
Views: 1609
Size:  9.5 KB

    Name:  dgv-header2.jpg
Views: 1627
Size:  9.8 KB

    Name:  dgv-header3.jpg
Views: 1627
Size:  9.8 KB

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    304

    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:
    1. <runtime>
    2.         <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=true" />
    3.     </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
  •  



Click Here to Expand Forum to Full Width