Tabbing Question

SaintJimmy

Member
Joined
Jul 7, 2006
Messages
24
Programming Experience
5-10
This may be a really simple question, but I can't get it to work for some reason.

I've got a form with a datagrid control on it. And I want the datagrid to relenquish focus to the next control in the tab order when the user hits the tab key, rather than the default behavior of tabbing to the next cell. Here's the procedure I wrote to attempt this, but it only works for tabbing to the previous control (when shift+tab is used). What am I doing wrong here?

VB.NET:
    Private Sub dgCustomers_KeyUp(ByVal sender As System.Object, _ 
  ByVal e As System.Windows.Forms.KeyEventArgs) _ 
  Handles dgCustomers.KeyUp
        If e.KeyCode = Keys.Tab Then
            Dim nextctl As Control
            If e.Shift Then
                nextctl = Me.GetNextControl(dgCustomers, False)
                nextctl.Focus()
            Else
                nextctl = Me.GetNextControl(dgCustomers, True)
                nextctl.Focus()
            End If
        End If
    End Sub
 
Look through the properties.... there should be something along the lines of "TabBehavior" or "StandardTab" or something like that, either way, the description of it will be "Controls wether the TAB key moves to the next cell or the next control."

-tg
 
New to '05?

Is that property something that's new to VS 2005? Because I'm using 2003 and I don't see any properties similar to what you're suggesting.
 
Figures.... I thought it was there in 2003 as well.... Hmmm.....

What is the next control in the list? Is it something that can accept focus?

-tg
 
No, that's the strange thing about it.

No, actually it's not. The DataGrid itself is nested pretty deep. I've got 2 splitters that make for a 3-panel view, but I've also got panels within the panels for docking. The DataGrid is in a panel by itself. The really odd thing is that the GetNextControl method is actually finding a control of type "HScrollBar" which I do not have anywhere on the form. And even with the method I have in place (see previous post), the grid is tabbing through it's cells as it does by default.

The next item in the tab order that receives a tab stop is a textbox control, which I've tried to reference by name and put the focus on it when the DataGrid receives a tab, but another problem is that apparently the focus changes are done on the "KeyDown" event and I'm unable to receive that event from the DataGrid. It's as if the DataGrid just doesn't fire that event at all. Could that be another bug similar to the DoubleClick event not firing in a ComboBox? If so, good going Microsoft... I'm practically convinced now that I must upgrade to 2005.
 
Back
Top