I have a form containing a tab control
I want focus set to a particular text box when the form opens.
However doing this in the load form event
If TabControl1.Sel ectedIndex = 0 Then
If txtFileName.Can Focus Then
txtFileName.Foc us()
End If
End If
I get false from canfocus.
I can do it fine in the tabcontrol.sele ctedindexchange d event so why
can't I do it in load?
Thanks 2 1575
On 2005-06-08, Jack Russell <ja***@norubbis h.tpg.com.au> wrote: I have a form containing a tab control I want focus set to a particular text box when the form opens.
However doing this in the load form event If TabControl1.Sel ectedIndex = 0 Then If txtFileName.Can Focus Then txtFileName.Foc us() End If
End If I get false from canfocus.
I can do it fine in the tabcontrol.sele ctedindexchange d event so why can't I do it in load?
Thanks
Controls have not necessarily completed their initilization in the
form's load event. A control to receive the focus, must be enabled,
visible, and have a handle. You may want to move this code to the forms
activated event - though, you will want to put a flag to make sure this
only happens the first time the activated event fires.
You might also make this happen if you do something like:
Me.Visible = True
Me.Refresh
If txtFileName.Can Focus Then
txtFileName.Foc us ()
End If
In your load event. This will force the form to become visible and
redraw it self....
--
Tom Shelton [MVP]
Tom Shelton wrote: On 2005-06-08, Jack Russell <ja***@norubbis h.tpg.com.au> wrote:
I have a form containing a tab control I want focus set to a particular text box when the form opens.
However doing this in the load form event If TabControl1.Sel ectedIndex = 0 Then If txtFileName.Can Focus Then txtFileName.Foc us() End If
End If I get false from canfocus.
I can do it fine in the tabcontrol.sele ctedindexchange d event so why can't I do it in load?
Thanks
Controls have not necessarily completed their initilization in the form's load event. A control to receive the focus, must be enabled, visible, and have a handle. You may want to move this code to the forms activated event - though, you will want to put a flag to make sure this only happens the first time the activated event fires.
You might also make this happen if you do something like:
Me.Visible = True Me.Refresh If txtFileName.Can Focus Then txtFileName.Foc us () End If
In your load event. This will force the form to become visible and redraw it self....
Tom,
Thanks,
Had tried it in the activated event to no avail but your second
suggestion worked thanks
Jack This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jesper Dannemamm |
last post by:
Hi
I am having trouble setting focus on
I tried using this script in the usercontrol's page_load sub to set focus on
a textbox with the ID = "user_name":
Page.RegisterStartupScript("focus", "<script
language=""JavaScript"">document.getElementById.user_name.focus();</script>
")
|
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...
|
by: Shravan |
last post by:
Hi,
I have a Windows Forms Custom DataGrid, which is put in a
usercontrol, which on setting DataSource is setting focus
to grid. The call stack for setting the focus is as
follows. This is not happened always whenever DataSource
is set, only called sometimes, in a series of setting
DataSource, I could get this setting focus only one time .
Can anybody help me how to stop this one.
system.windows.forms.dll!
|
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();
|
by: Steve Yerkes |
last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There are a couple of people selling components... but that is not really an option for me... So, I took the plunge and modified the "WebUIValidation.js" file to make it happen... After tracing through file, I figure it out. It was actually pretty...
| |
by: Brian Henry |
last post by:
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...
|
by: clickon |
last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,
TextBox1.Text ="foo";
and
TextBox2.Text = "bar";
|
by: Zytan |
last post by:
I want to set a control in a form to have the default focus.
This is not the accept button -- that's set to a button when is
'clicked' when you press ENTER. I want a textbox to have the focus
when the form is loaded. The textbox cannot be the first in the Tab
order, since it's not at the top of the window, and it seems silly to
start the tab order at it just to fix this issue. I cannot call
control.Focus() from Form1_Load() since...
|
by: Finn Stampe Mikkelsen |
last post by:
Hi
How can i set a focus to a textbox in my codebehind page??
I have this WebForm, that takes information from a user and 2 buttons on the
form. One that takes action on the entered information and one that resets
the form...
The second on, the reset button, i would like to set focus back to the first
textbox on the form. I already have an onload in my body, which sets the
|
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
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |