Results 1 to 4 of 4

Thread: [RESOLVED] Select DatagridView Row Header.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Resolved [RESOLVED] Select DatagridView Row Header.

    I want to delete a datagridview row by selecting the header row and hitting the Delete key.

    Starting with another textbox control having focus, then clicking a datagridview row header (which highlights the row), the focus remains with (or returns to) the original control.
    The only way I can delete a row is if I first enter a cell and then select the row header.

    This is may already be obvious from the behaviour I describe (or possibly irrelevant) but I have "SelectionMode = FullRowSelect" and "EditMode = EditOnKeystrokeOrF2"

    Can anyone suggest what tweak might be needed to fix this?
    Last edited by sgrya1; Nov 22nd, 2021 at 01:07 PM.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,517

    Re: Select DatagridView Row Header.

    Maybe recheck your property settings. With those SelectionMode and EditMode settings all you should need to do is select a row header and press the delete key.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Select DatagridView Row Header.

    You are right. It does work.
    For some reason I wasn't thinking CellEnter was an event triggered by clicking the row header.
    In that event I had something that was taking the focus away.
    Thank you!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [RESOLVED] Select DatagridView Row Header.

    The headers of both rows and columns are considered cells, with indexes of -1 if I'm not mistaken. If you filter for a column index of >= 0 in your CellEnter event handler then I think that you would act on only the data cells and not the row headers. You might need an additional filter for column headers too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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