473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

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
8 10433
"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
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
"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
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
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Corepaul | last post by:
I am a newbie using Access 2000. I am using the following test in the txtAlbum OnExit procedure to prevent leaving an empty text box for a required field If (IsNull(txtAlbum.Value)) Or...
2
by: MLH | last post by:
At first, I thought it might be WhichFormOpenedMe.SetFocus, but I don' think so. Anyone know the answer?
4
by: amywolfie | last post by:
I would like to put code behind a Find button on a form which: 1) Performs a find based on a field on the form 2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box. ...
1
by: Eric E | last post by:
Hi all, I have a subform placed on a tab control, and I'm having a terrible time with proper tab order. I'm trying to allow the user to tab from the last control on my subform to a control on the...
1
by: AA Arens | last post by:
I use the undermentioned code to find a record in a predefined "Look In" field: Private Sub Command137_Click() On Error GoTo Err_Find_Record_Click Me.CompanyName.SetFocus DoCmd.DoMenuItem...
3
by: frenchy | last post by:
I am getting this error in Adobe after struggling with a 'submit' button on an acrobat form that is in production and all the other appdev people in the office are NOT having a problem with. It...
3
by: Dale | last post by:
Access 2000 I am trying to check the form to be sure that required fields are entered. For each required field (Control) I have set the tag property to "1". I am trying to loop through all...
6
by: linuxnooby | last post by:
Hi I want a form field to be selected when the page loads. But I get the error message Error: document.getElementById("ff") has no properties any ideas what I am doing wrong? code below
1
by: brboga | last post by:
Hello, VBA gives an error on the indicated line. "tblparameters" is a database which exists. Option Compare Database Option Explicit Sub fill_parameters()
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.