473,795 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting focus doesn't work

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.Pas swordChar = bdbGeneral.PASS WORDCHAR ' make the better looking
mask character (chrW is unicode characters)

' set live as the default

Me.cboDatabase. value = settings.ReadSe tting("initialD atabase")

Me.txtPassword. Text = "password"

Me.txtUser.Text =
System.Security .Principal.Wind owsIdentity.Get Current.Name(). Substring(Syste m
..Security.Prin cipal.WindowsId entity.GetCurre nt.Name.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
3 5627
"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
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*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
"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
"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.focu s
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
12308
by: Arne | last post by:
During testing <div style="overflow:auto;"> in CSS I noticed the mousewheel would work in Mozilla only after I made a <a href="#">some text</a> link and clicked on that, within the div. It appears as if Mozilla needs to have the focus set on that div in order for the mousewheel to work. That's all that link does. The mousewheel works perfectly in IE without the link. It scrolls the div even if there is a scrollbar on the page. Is...
0
1898
by: ED M. | last post by:
Hello all...I'm new to the board. I have a problem that I hope someone here might be able to solve for me. I am doing some clientside validation using Javascript. The text I am testing is within a textbox that is part of a datagrid. To complicate things, the datagrid is part of a user control. The following code is all part of the user control. The validation part of the script works fine. However, when I try to set the focus...
2
7406
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to activate the MDI is something like the following: frmTest frm = new frmTest(); frm.MdiParent = this; frm.Show();
1
6364
by: Rachel Suddeth | last post by:
I have an form where the whole display is a tab control (well, that plus a status bar.) I want to set the focus to the first TextBox on the first TabPage when it loads. I tried to put that into the FormLoad event, but the form still comes up with the focus on the tab for the first tab page. Anyone know how to do this? Here is what I tried (but simplified)... ----------------
12
4909
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function cmdButton1_Clicked() { document.all('txtInput1').focus(); return false; }
4
1932
by: Aung Thu | last post by:
Hi, there! I want to set focus on a control, of which TabIndex is not the first, when a form is loaded. In the form's load event, I have used Control.Focus() but it doesn't not work. The focus is not on the control I set. The focus is always on the control of which TabIndex is 0. Thanks.
3
1673
by: register_allocation | last post by:
I have a frameset where I call a JavaScript function in the onLoad method: .... <frameset cols="..." onLoad="setFn()"> ... <frame name="data_frame" ...> </frameset> In setFn, I am dynamically loading the contents of the 'data_frame', which works fine. I then want to set focus to the 'data_frame':
3
2168
by: kelvin.koogan | last post by:
I have a number of controls on a tab page. I want to validate them all when the user tries to leave the tab. I then want to highlight the first control which fails validation. How can I do this? I try setting focus but something seems to set the focus back to the control which had it before validation. Any ideas? TIA, KK
3
2438
by: zacks | last post by:
I am working on an application that has a UI that supports multiuple functions by means of a group of "plug ins". Each plugin is a class library. Each plugin contains a User Control that defines the controls for that plugin's main form. The UI has a PictureBox control that is nothing but a contain to add the UserControl from the selected plugin, so that when the user selects a plugin, the main form changes appearance to the UserControl in...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.