|
-
Jul 21st, 2011, 01:22 PM
#1
Thread Starter
Fanatic Member
Leave a control with code?
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
-
Jul 21st, 2011, 01:29 PM
#2
Lively Member
Re: Leave a control with code?
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
-
Jul 21st, 2011, 01:35 PM
#3
Fanatic Member
Re: Leave a control with code?
You can use
Code:
Me.SelectNextControl(Me.TextBox2, False, True, True, True)
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.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Jul 21st, 2011, 01:49 PM
#4
Thread Starter
Fanatic Member
Re: Leave a control with code?
I'm trying to enter TextBox2 without firing it's enter event twice.
-
Jul 21st, 2011, 02:22 PM
#5
Fanatic Member
Re: Leave a control with code?
You can control what textbox has focus using SelectNextControl. I'm not sure what you mean by this
I'm trying to enter TextBox2 without firing it's enter event twice.
Maybe you could explain exactly what you are trying to do.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Jul 21st, 2011, 02:53 PM
#6
Thread Starter
Fanatic Member
Re: Leave a control with code?
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|