Is there a way to leave a control in code without explicitly going to the next control? For example, I want to
Me.TextBox1.Text = "abc"
Me.TextBox1.Leave
Not
Me.TextBox1.Text = "abc"
Me.TextBox2.Select
Printable View
Is there a way to leave a control in code without explicitly going to the next control? For example, I want to
Me.TextBox1.Text = "abc"
Me.TextBox1.Leave
Not
Me.TextBox1.Text = "abc"
Me.TextBox2.Select
Is the selectnextcontrol function what you want? Signature is below.
Public Function SelectNextControl(ByVal ctl As System.Windows.Forms.Control, ByVal forward As Boolean, ByVal tabStopOnly As Boolean, ByVal nested As Boolean, ByVal wrap As Boolean) As Boolean
You can use
The first True or False option here is set to False. That determines whether you want to move forward or backward in the tab order. True to move forward and False to move backward. You want to enter text into a textbox and then keep the focus at that textbox? If TextBox2 is the next textbox in the tab order after TextBox1 then this code should set the focus to TextBox1.Code:Me.SelectNextControl(Me.TextBox2, False, True, True, True)
I'm trying to enter TextBox2 without firing it's enter event twice.
You can control what textbox has focus using SelectNextControl. I'm not sure what you mean by this
Maybe you could explain exactly what you are trying to do.Quote:
I'm trying to enter TextBox2 without firing it's enter event twice.
TextBox2 has a voice prompt. If you say Me.TextBox2.Select the voice prompt is heard twice because TextBox2's enter event fires twice. Currently I'm using a boolean variable to control this. I'm looking for a better way.