473,406 Members | 2,894 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,406 software developers and data experts.

Determining which control has input focus?

What's the best way to determine in code which control on a form has input
focus?

I'm programming an edit menu (the usual cut, copy, paste), which needs to
target one of several text boxes on its form. Specifically, the menu needs
to target the text box that has the input focus. For the moment I'm assuming
there will be no controls on the form except the menu and the text boxes.

I've found code to drive the clipboard edit methods. But none of the
examples shows how to determine which text box has the input focus. They all
assume the method there is only one text box on the form. So, what I'm
puzzling over is this: Is there a simple way to determine which text box has
the focus, or do I need to iterate through all controls on the form?

Thanks.

--
Dave Veeneman
Chicago
Nov 15 '05 #1
3 1842
Hi Dave,

Does ActiveControl property help?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Dave Veeneman" <da****@nospam.com> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
What's the best way to determine in code which control on a form has input
focus?

I'm programming an edit menu (the usual cut, copy, paste), which needs to
target one of several text boxes on its form. Specifically, the menu needs
to target the text box that has the input focus. For the moment I'm assuming there will be no controls on the form except the menu and the text boxes.

I've found code to drive the clipboard edit methods. But none of the
examples shows how to determine which text box has the input focus. They all assume the method there is only one text box on the form. So, what I'm
puzzling over is this: Is there a simple way to determine which text box has the focus, or do I need to iterate through all controls on the form?

Thanks.

--
Dave Veeneman
Chicago

Nov 15 '05 #2
I found my answer. Forms (and other containers) have an ActiveControl
property that returns the control with focus.
Nov 15 '05 #3
Yes-- thanks!
Nov 15 '05 #4

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

Similar topics

4
by: Paul Thompson | last post by:
How do I determine in JavaScript the name of the object that focus is on?
0
by: Vinod. | last post by:
Hi all, I have added browser control to a windows form. I am loading pages having multiple frames. I have noticed that the focus in a text is not maintained when the application is deactivated....
12
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...
10
by: Dennis D. | last post by:
Hello: There are a series of textboxes (x.text, y.text, z.text etc.) in which user input is expected. As: dtmX=CDate(x.text) dtmY=CDate(y.text) dtmZ=CDate(z.text) where x, y, and z.text...
0
by: steve | last post by:
i've built serveral controls designed for touch-screen use. i have a quirk with one and am not sure how to solve the problem. it is a drop-down style combo box that filters list items as the input...
4
by: Stefan Mueller | last post by:
In my example the focus should only jump to textbox2 when you press the tab key if '11' is in textbox1. If the value of textbox1 is not '11' than the focus should be set back to textbox1. That...
0
by: Joseph | last post by:
I have two TextBoxes so a user can enter a start and end date using a calendar control. I am using the <Calendar1_SelectionChanged> method to input the date in the textbox. My question is this: Is...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
1
by: orico | last post by:
Hello all, I have a few '<input type="text" />' controls on my ASP.NET 2.0 generated page. Every text-box control has it's specific tab-index. When I try to move focus to this specific text-box...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
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,...
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,...
0
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...

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.