473,320 Members | 1,946 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,320 software developers and data experts.

Form_Load (how to focus a control ?)

Hello,

I would like to focus on a special control on my form during Form_Load
inialisation. The focused control may change according to internal
parameter value (so it's not always the same control).

How to do it ?

Example :
tbName.Focus();

My problem is that within the FormLoad, setting focus on a control does
not seem to have effect.
Regards,
Cybertof.
Nov 15 '05 #1
4 3806
The control with the smallest (by this I mean a is smaller than b if a < b)
TabIndex is focused on startup automatically. Change this property of the
control you want to have the initial focus.

Hope that helps,
-JG
Nov 15 '05 #2
I use a timer object to set the focus after the Form loads.

Drop a Timer control on the form set it to Enable = true, Interval = 1. Then
register the Tick event.

In the handler for that event set the focus to the desired control. That
allows you to keep your tab order in tact.

HTH;
Eric Cadwell
http://www.origincontrols.com
Nov 15 '05 #3
If you use groupboxes, you may need to set focus to the groupbox before
setting focus to a control within it. Same with panels, or any controls
that can contain other controls.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #4
Thanks all.

I have found another method : setting the focus in the activate event,
so i'm sure all the controls are visible when focusing on them.

Unfortunately, i have to deal with a status boolean flag saying so my
focusing operates only the first time it activates (after the load).

The TabIndex is good if the control to have focus does not change
according to custom settings.
In my cas, i had to do it programmaticaly.
Bad luck that it cannot be done in the form_load event.
Regards,
Cybertof.
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for...
2
by: kea | last post by:
I have a checkbox and a textbox in a continuous taborder on a form along with a bunch of other controls. The textbox is disabled. When I leave the checkbox I want to enable the textbox and move...
6
by: deko | last post by:
Is there a difference between the Form_Open and Form_Load events? When should I use one rather than the other? I have several forms that require code to run when they open... or is it when they...
2
by: ad | last post by:
I used ASP.NET 2.0. When I edit a row in a GridView. How can I set the focus to the first editable column?
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
4
by: Jon Slaughter | last post by:
I've created some custom controls and forms that allow the feature to temporarily transfer focus to a control that has been entered by the mouse. Everything seems to work fine but the problem I...
2
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about...
10
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
2
by: ezechiel | last post by:
Hi, I have the following (limited to problem): 2 tables: software (sw_id (pk), sop_id(fk)) sop(sop_id, sop_name, sop_nr) In the form (actually a software record): - a combobox ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.