Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6766019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:46:49+00:00 2026-05-26T14:46:49+00:00

We discovered a possible bug involving the DataGridView. The DataGridView has a property, StandardTab,

  • 0

We discovered a possible bug involving the DataGridView. The DataGridView has a property, StandardTab, that is set to False by default. This default setting means that the TAB key moves between cells within the grid. When it reaches the final cell in the grid, then the TAB key moves focus to the next control. This is the setting we are using in our project.

The DataGridView is connected to a binding source in our project, which may or may not be relevant.

When the DataGridView is on a form that is being displayed from a COM-based project (VB6, in our case), the grid control loses focus when the user tries to tab within the grid. If you hold down the tab key, focus cycles through other controls on the form until it returns to the grid. When it returns to the grid, the selected cell is the one that the user was tabbing to.

So, it is possible for the user to navigate through all the cells, via a detour through the rest of the controls on the form as they move from cell to cell. This does not make for happy users.

I did find an MSDN forum question that seems to describe this problem, but the only answer to it is not terribly helpful.

I could submit this as a bug on Microsoft Connect, but I doubt they are going to fix it. Is there a way to deal with this issue in code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:46:49+00:00Added an answer on May 26, 2026 at 2:46 pm

    Further investigation of the following events/methods revealed a pattern:
    Leave (on the control)
    ProcessDialogKey (on the form and on the control)
    ProcessDataGridViewKey (on the control)

    The last two events turned out to be key to the problem.

    When we tested in a 100% .NET project, we discovered that tabbing internally would execute the ProcessDataGridViewKey event to fire. When on the last cell, the ProcessDataGridView function was not executed, but the ProcessDialogKey function was executed.

    When we tested in the Interop project, the events were exactly the same, but a Leave event on the control occurred before the ProcessDataGridViewKey function was executed. The bad scenario is unique in that the control will not have focus then ProcessDataGridViewKey function is executed.

    Perhaps we can test for that and make focus come back to the control? It turns out that we can, and here is a subclassed control that handles it, yet still works fine in a 100% .NET project.

    Public Class DataGridViewCustom : Inherits DataGridView
        Protected Overrides Function ProcessDataGridViewKey(e As System.Windows.Forms.KeyEventArgs) As Boolean
            ' When the grid is hosted by a form that is being loaded through the Interop Forms Toolkit,
            ' the default behavior of using the TAB key to navigate between cells is broken 
            ' (StandardTab = False). The tab key causes the grid control to lose focus before it has a 
            ' chance to process the tab key in this event handler.
            '
            ' This handler is not executed when the TAB key is supposed to make it lose focus (i.e. when
            ' StandardTab is True or when TABbing off the last cell within the grid). In those 
            ' scenarios, the ProcessDialogKey event handler is executed, and there is no problem.
            ' Therefore, we can assume that if this event is being processed, and the grid does not have
            ' focus, we should put focus back on the control.
    
            ' The datagridview has different behavior for TAB and CTL-TAB, depending on how the StandardTab
            ' property is set. We don't have to worry about that becuase this method only executes when the
            ' focus is supposed to stay within the control. A different method is executed when the focus
            ' is supposed to leave the control.
    
            If e.KeyCode = Keys.Tab AndAlso Not Me.Focused Then Me.Focus()
    
            Return MyBase.ProcessDataGridViewKey(e)
        End Function
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have discovered recently that's possible to call anoymous blocks from jdbc like this:
I discovered that it is possible to extract the hard-coded strings from a binary.
Possible Duplicate: Encrypting/Hashing plain text passwords in database Recently, I discovered that major web
Yesterday I discovered an odd bug in rather simple code that basically gets text
I've got a project where I've just discovered that warning C4244 (possible loss of
I just discovered, quite by accident, that this seems to work: Public Interface Ix
This question indicates that it is possible for a 32-bit COM client to talk
I discovered that it is possible to create command-line programs via C++. I am
Possible Duplicate: C++ source in unicode I just discovered this line of code in
I've discovered that in Visual Studio 2010 Professional it is possible to refresh the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.