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

Setting focus doesn't work

P: n/a
Hi,

I have a bunch of forms in a DLL that I call from my main application. The
one form is a login form, and I have the tab order set in the order I want
it (password box first, then ok button then cancel button then database
selection combo box then user name text box, then back to password text box)
now the password, user name and database entry's are in a group box frame.
the buttons (Ok and Cancel) are outside the group frame.

Now that the tab order is set, I want to set focus by default to the
password text box. The user name is entered automaticly by the system as per
the current user logged into active directory on the system. (of course the
user can change who logs in by changeing the text box). When I do this in
the load event

txtPassword.PasswordChar = bdbGeneral.PASSWORDCHAR ' make the better looking
mask character (chrW is unicode characters)

' set live as the default

Me.cboDatabase.value = settings.ReadSetting("initialDatabase")

Me.txtPassword.Text = "password"

Me.txtUser.Text =
System.Security.Principal.WindowsIdentity.GetCurre nt.Name().Substring(System
..Security.Principal.WindowsIdentity.GetCurrent.Na me.IndexOf("\") + 1)

Me.txtPassword.Focus()

now, when I run the form, txtpassword does not have focus. The focus is
starting on the cancel button. I do have the cancel button as the form
default cancel button and the ok button as the forms default acept button.
What is causeing this and how would i fix it? I thought using the focus
method was going to give teh textbox gocus.... it has in the past.. thanks
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Brian Henry" <brianiup[nospam]@adelphia.net> schrieb
Me.txtPassword.Focus()

now, when I run the form, txtpassword does not have focus. The focus
is starting on the cancel button. I do have the cancel button as the
form default cancel button and the ok button as the forms default
acept button. What is causeing this and how would i fix it? I thought
using the focus method was going to give teh textbox gocus.... it has
in the past.. thanks


Did you also set the tabindex of the groupbox? Must be smaller than the
one's of the buttons.

An important precondition to be able to set the focus (see docs on Focus
method) is not met: the form is not visible within form_load.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
how would you go about setting the default focus then if you can not set it
on load (i ask this because this is how we do it in foxpro and a few other
languages ive worked with)? thanks

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Brian Henry" <brianiup[nospam]@adelphia.net> schrieb
Me.txtPassword.Focus()

now, when I run the form, txtpassword does not have focus. The focus
is starting on the cancel button. I do have the cancel button as the
form default cancel button and the ok button as the forms default
acept button. What is causeing this and how would i fix it? I thought
using the focus method was going to give teh textbox gocus.... it has
in the past.. thanks


Did you also set the tabindex of the groupbox? Must be smaller than the
one's of the buttons.

An important precondition to be able to set the focus (see docs on Focus
method) is not met: the form is not visible within form_load.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
"Brian Henry" <brianiup[nospam]@adelphia.net> schrieb
how would you go about setting the default focus then if you can not
set it on load (i ask this because this is how we do it in foxpro and
a few other languages ive worked with)? thanks


If setting the tabindex does not work...

In the activated event:

static done as boolean

if not done then
done=true
thecontrol.focus
end if
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.