Determining which control has input focus?


D

Dave Veeneman

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.
 
Ad

Advertisements

D

Dave Veeneman

I found my answer. Forms (and other containers) have an ActiveControl
property that returns the control with focus.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top