none
Hide highlight on datagridview

    Question

  • Hello

    Is there any posibilities to hide the highlighted square selection on a datagridview?


    Thanks in advance, Ciprian LUPU
    Friday, February 11, 2011 5:43 PM

Answers

  • Sorry I didn't was so explicit.

    I want to select a cell but not to see the suare around the cell with dotted line. (sorry for my english)


    Thanks in advance, Ciprian LUPU


    Well, try handling RowPrePaint event and put this inside that event handler like this:

     Private Sub dataGridView1_RowPrePaint(ByVal sender As Object, _
            ByVal e As DataGridViewRowPrePaintEventArgs) _
            Handles dataGridView1.RowPrePaint

            ' Do not automatically paint the focus rectangle.
    e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus
    End Sub


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    • Marked as answer by Ciprian Lupu Friday, February 11, 2011 6:37 PM
    • Edited by Onur Güzel Friday, February 11, 2011 6:38 PM
    Friday, February 11, 2011 6:34 PM

All replies

  • Hello

    Is there any posibilities to hide the highlighted square selection on a datagridview?


    Thanks in advance, Ciprian LUPU


    Which highlight do you mean? Row or cell selection/highlight by calling "square"?

    To hide row highlight:

     DataGridView1.CurrentRow.Selected = False

    To hide cell highlight:

    DataGridView1.CurrentCell.Selected = False

     


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    Friday, February 11, 2011 6:15 PM
  • Sorry I didn't was so explicit.

    I want to select a cell but not to see the suare around the cell with dotted line. (sorry for my english)


    Thanks in advance, Ciprian LUPU
    Friday, February 11, 2011 6:22 PM
  • Sorry I didn't was so explicit.

    I want to select a cell but not to see the suare around the cell with dotted line. (sorry for my english)


    Thanks in advance, Ciprian LUPU


    Well, try handling RowPrePaint event and put this inside that event handler like this:

     Private Sub dataGridView1_RowPrePaint(ByVal sender As Object, _
            ByVal e As DataGridViewRowPrePaintEventArgs) _
            Handles dataGridView1.RowPrePaint

            ' Do not automatically paint the focus rectangle.
    e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus
    End Sub


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    • Marked as answer by Ciprian Lupu Friday, February 11, 2011 6:37 PM
    • Edited by Onur Güzel Friday, February 11, 2011 6:38 PM
    Friday, February 11, 2011 6:34 PM
  • Hey, you're good!!!
    Thank you very very very much.


    Thanks in advance, Ciprian LUPU
    Friday, February 11, 2011 6:37 PM
  • Can I do somehow in the same manner with a Button?
    Thanks in advance, Ciprian LUPU
    Friday, February 11, 2011 6:39 PM
  • Hello Ciprian,

    Thanks for your post.

    What do you mean "the same manner with a button"? When you select the button, you want to hide the highlighted square selection with dotted line in design time? Could you please describe this issue more clearly?

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 14, 2011 5:58 AM
  • Hi All,

    I've done extensive searches on this for an app I'm working on. A lot of overly complex solutions seen.

    One of the problems with most solutions is the re-highlight when the DataGridView is re-sorted. 

    This one seems to always work: 

    DataGridView1.CurrentCell = Nothing

     

    KISS principle.

    Wednesday, December 28, 2011 2:07 PM
  • Excellent man. Thanks
    Monday, July 16, 2012 6:28 AM
  • Sorry I didn't was so explicit.

    I want to select a cell but not to see the suare around the cell with dotted line. (sorry for my english)


    Thanks in advance, Ciprian LUPU


    Well, try handling RowPrePaint event and put this inside that event handler like this:

     Private Sub dataGridView1_RowPrePaint(ByVal sender As Object, _
            ByVal e As DataGridViewRowPrePaintEventArgs) _
            Handles dataGridView1.RowPrePaint

            ' Do not automatically paint the focus rectangle.
    e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus
    End Sub


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)


    THANK YOU

    stelios ----------

    Monday, January 13, 2014 8:31 AM