By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,569 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,569 IT Pros & Developers. It's quick & easy.

VB.NET equiv to VB 6.0 "SetFocus()"

P: n/a
Q: How many licks DOES it take to get to the center of a Tootsie Pop?

err... on a more serious note:

What is the VB.NET equivalent of the VB 6.0 "control.SetFocus()" event?

Thanks in advance, and I hope the one-liner was non-offensive :)
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:eR**************@TK2MSFTNGP14.phx.gbl...

What is the VB.NET equivalent of the VB 6.0 "control.SetFocus()" event?


control.Focus()
Nov 21 '05 #2

P: n/a
I tried that ... didn't work 8^/ ... am now wondring if the (retail)
controls I am using are the culprit. I'm gong to add a generic Windows
control of the same calibre to the form, and set focus to it, and see if
that fires...

BRB...
"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:eR**************@TK2MSFTNGP14.phx.gbl...

What is the VB.NET equivalent of the VB 6.0 "control.SetFocus()" event?


control.Focus()

Nov 21 '05 #3

P: n/a
"Newsgroups" <ne********@idbdeveloper.com> schrieb:
I tried that ... didn't work 8^/ ... am now wondring if the (retail)
controls I am using are the culprit. I'm gong to add a generic Windows
control of the same calibre to the form, and set focus to it, and see if
that fires...


Make sure the control you are attempting to set the focus to is both enabled
and visible.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
Two part failure analysis:

Part 1 -- Failed: Added a standard TextBox control to the form (within a
Retail Control that has "Me.Dock = DockStyle.Fill" enabled)

Part 2 -- Failed:
-- Added a generic Form1 to the project
-- Added three (3) generic Textboxes to the generic Form
-- Added TextBox3.focus() to Form1's Load event
-- Added a generic Button to the Retail-Control-based form
-- Added dialog to open Form1
-- Compiled & Ran
-- >>> TextBox1 had the focus.

I am totally baffled with this one.

Any more suggestions greatly appreciated :)
"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:eR**************@TK2MSFTNGP14.phx.gbl...

What is the VB.NET equivalent of the VB 6.0 "control.SetFocus()" event?


control.Focus()

Nov 21 '05 #5

P: n/a
"Newsgroups" <ne********@idbdeveloper.com> schrieb:
Part 1 -- Failed: Added a standard TextBox control to the form (within a
Retail Control that has "Me.Dock = DockStyle.Fill" enabled)

Part 2 -- Failed:
-- Added a generic Form1 to the project
-- Added three (3) generic Textboxes to the generic Form
-- Added TextBox3.focus() to Form1's Load event
-- Added a generic Button to the Retail-Control-based form
-- Added dialog to open Form1
-- Compiled & Ran
-- >>> TextBox1 had the focus.


At the time when the form's 'Load' event handler executes, the textbox is
invisible and thus the focus is not set. Either set the focus after the
form is shown or adjust the tab order of the controls (property 'TabIndex',
'TabStop') in a way that the third textbox has the lowest 'TabIndex'. The
thread referenced below contains some hints on how to implement a 'Shown'
event for a form:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/2943a7b7afa079f8>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

P: n/a
Thank you Herfried. Will try referenced article below.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uT*************@TK2MSFTNGP12.phx.gbl...
"Newsgroups" <ne********@idbdeveloper.com> schrieb:
Part 1 -- Failed: Added a standard TextBox control to the form (within a
Retail Control that has "Me.Dock = DockStyle.Fill" enabled)

Part 2 -- Failed:
-- Added a generic Form1 to the project
-- Added three (3) generic Textboxes to the generic Form
-- Added TextBox3.focus() to Form1's Load event
-- Added a generic Button to the Retail-Control-based form
-- Added dialog to open Form1
-- Compiled & Ran
-- >>> TextBox1 had the focus.


At the time when the form's 'Load' event handler executes, the textbox is
invisible and thus the focus is not set. Either set the focus after the
form is shown or adjust the tab order of the controls (property
'TabIndex', 'TabStop') in a way that the third textbox has the lowest
'TabIndex'. The thread referenced below contains some hints on how to
implement a 'Shown' event for a form:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/2943a7b7afa079f8>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7

P: n/a
Hi,

"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Two part failure analysis:

Part 1 -- Failed: Added a standard TextBox control to the form (within a
Retail Control that has "Me.Dock = DockStyle.Fill" enabled)

Part 2 -- Failed:
-- Added a generic Form1 to the project
-- Added three (3) generic Textboxes to the generic Form
-- Added TextBox3.focus() to Form1's Load event
-- Added a generic Button to the Retail-Control-based form
-- Added dialog to open Form1
-- Compiled & Ran
-- >>> TextBox1 had the focus.

I am totally baffled with this one.

Any more suggestions greatly appreciated :)
You can't set focus if the TextBox isn't fully loaded (Form Load), but you
can activate it, the active control should get focused when the form is done
loading. Use Select() instead of Focus() to activate a control:

In Form Load Event:
TextBox3.Select()
HTH,
Greetings


"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:eR**************@TK2MSFTNGP14.phx.gbl...

What is the VB.NET equivalent of the VB 6.0 "control.SetFocus()" event?


control.Focus()


Nov 21 '05 #8

P: n/a
Thanks Bart, will try ...

"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
Hi,

"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Two part failure analysis:

Part 1 -- Failed: Added a standard TextBox control to the form (within a
Retail Control that has "Me.Dock = DockStyle.Fill" enabled)

Part 2 -- Failed:
-- Added a generic Form1 to the project
-- Added three (3) generic Textboxes to the generic Form
-- Added TextBox3.focus() to Form1's Load event
-- Added a generic Button to the Retail-Control-based form
-- Added dialog to open Form1
-- Compiled & Ran
-- >>> TextBox1 had the focus.

I am totally baffled with this one.

Any more suggestions greatly appreciated :)


You can't set focus if the TextBox isn't fully loaded (Form Load), but you
can activate it, the active control should get focused when the form is
done loading. Use Select() instead of Focus() to activate a control:

In Form Load Event:
TextBox3.Select()
HTH,
Greetings


"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
"Newsgroups" <ne********@idbdeveloper.com> wrote in message
news:eR**************@TK2MSFTNGP14.phx.gbl...

What is the VB.NET equivalent of the VB 6.0 "control.SetFocus()" event?
control.Focus()



Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.