How do I programmatically determine which control has focus?

You can programmatically determine which control currently has focus by means of the form's ActiveControl property.

For example, in C#:

Control cntrl = this.ActiveControl;

And in VB .NET:

Dim cntrl As Control = Me.ActiveControl

© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/05/04
Comment or report problem with topic