Does anyone know how to determine which control on a form currently has focus?

if you are working within a form you can use this enumeration to solve the problem

foreach( Control oControl in yourForm.Controls)
if(Control.Focus) MessageBox.Show(oControl.Name)
I think that will do the job

I found a better way - use the ContainerControl.ActiveControl property. So, in a form, you can just use this.ActiveControl .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.