Re: Setting the correct tabindex
- From: "Phill W." <p-.-a-.-w-a-r-d@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 15:01:42 +0100
Mike Eaton wrote:
Here's the problem: On condition A, I want input focus to go to a textbox on the panel when the form loads. On condition B, I want the input focus to go to the textbox that's on the form when the form loads. Seems pretty simple.
TabIndex only goes so far and, in this case, not far enough.
Youneed to forcibly move focus to another contorl, but you can't do that in Form_Load. The Form (and hence the Control) isn't visible, so won't accept focus - you have to wait until the Form appears, which is where the Activated event comes in.
Try this:
Private m_PendingFocus As Control = Nothing
Private Property PendingFocus() as Control
Get
Return m_PendingFocus
End Get
Set(Value as Control)
m_PendingFocus = Value
End Set
End Property
Private Sub Form_Activated( ... ) Handles MyBase.Activated
If Not (m_PendingFocus Is Nothing) Then
m_PendingFocus.Focus()
m_PendingFocus = Nothing
End If
End Sub
Private Sub Form_Load( ... ) Handles MyBase.Load
If ConditionA Then
Me.PendingFocus = TextBoxOnPanel
Else
' Do Nothing - the existing Tab Order will do
End If
End Sub
HTH,
Phill W.
.
- Prev by Date: Re: vb2003 and Sqlbase
- Next by Date: Re: Determine caller class name
- Previous by thread: phone number regular expression problem
- Next by thread: custom panel control
- Index(es):
Relevant Pages
|