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

how do i shift focus?

when the user log into my application, there is a dialog pop up with some
paramereters that need to set.

a radio button is default to checked and a textbox is right next to it. i
want the cursor or the ibeam to flash on the textbox so user don't have to
click on the textbox in order to enter input. how do i shift the focus?

i have the windows form load even with

this.rdTest.enabled = true;
this.txtTest.enabled = true;
this.txtTest.focus();

but it doesn't show the ibeam on the textbox. Can someone tell me how to do
this?

thank you.
Dec 8 '06 #1
2 1926
txtTest.Select()
--
Ciaran O''''Donnell
http://wannabedeveloper.spaces.live.com
"dotnetnoob" wrote:
when the user log into my application, there is a dialog pop up with some
paramereters that need to set.

a radio button is default to checked and a textbox is right next to it. i
want the cursor or the ibeam to flash on the textbox so user don't have to
click on the textbox in order to enter input. how do i shift the focus?

i have the windows form load even with

this.rdTest.enabled = true;
this.txtTest.enabled = true;
this.txtTest.focus();

but it doesn't show the ibeam on the textbox. Can someone tell me how to do
this?

thank you.
Dec 8 '06 #2
Hello!
txtTest.Select()
Correct, calling the Select method does the trick. Another option would be
to say:

this.ActiveControl = txtTest;

However, the way I read the original poster's question, he/she might also
want to consider setting the tab order correctly, in which case calling
Select in the Form_Load event is not necessary. The easiest way to set the
tab order with Visual Studio is to choose the View/Tab Order menu command on
the form design view, and then click the controls one by one in correct
order. Focus (the "ibeam") will then go to the first-clicked control
automatically without any code.

Also, a note about Focus vs. Select methods. From the class library
reference documentation:

"Focus is a low-level method intended primarily for custom control authors.
Instead, application programmers should use the Select method or the
ActiveControl property [...]"

This in addition to what Ciaran has already said.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Dec 8 '06 #3

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

Similar topics

10
by: Tim Frawley | last post by:
I am attempting to detect a Shift+Tab in the KeyPress event for back navigation on a control that doesn't support this method. Does anyone have any ideas how to compare e.KeyChar to a ShiftTab? ...
3
by: feng | last post by:
Hi, I have a MDI container that contains a treeview and a child form. Clicking on a tree node will open the child form. Right now, the focus stays with the treeview, even after the child form...
2
by: UJ | last post by:
How do you set the icon for when somebody presses Shift-Tab ? I have already set the application icon and the form icon but they aren't showing up in Shift-Tab. TIA - Jeff
7
by: Csaba Gabor | last post by:
I'd like to detect the shift key when a button is "clicked" in Firefox/Mozilla. If the button is clicked with the mouse, no problem. However, if the onclick event is keyboard originated, then my...
1
by: jonathanmcdougall | last post by:
I am developing a calendar on which dates can be clicked and selected. A calendar is a table in which each day is a cell. Each cell has a unique id. By left-clicking on a date, it gets selected...
6
hyperpau
by: hyperpau | last post by:
There is a certain feature in access that allows you zoom in a field to have a clearer view. For example, if the form is in datasheet view and the memo field only shows you the first few words of...
8
by: sudha412 | last post by:
hi guys. i am facing one issue. For one text box field i have used fillowing code. ---------------------------------------------------------------------------------------------------------...
1
by: Klaus Dasenbrock | last post by:
Hi, i send with PostMessage(HWND, WM_KEYDOWN, Keys.K, IntPtr.Zero) to the notepad the letter k now i wanna send with postmessage Shift+a =A, Shift++=* or Shift+1=! how can i do this with...
0
by: Jason Kester | last post by:
Silliest question ever: Had the disaster scenario in VS.NET yesterday. Fired up the IDE, only to find that I could no longer un-tabbify sections of code by selecting them and SHIFT+TABbing. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

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.