Focus problem

  • Thread starter Thread starter Keith Smith
  • Start date Start date
K

Keith Smith

I have a form with some comboBoxes and other controls. When tabbing through
the controls the cursor "disappears" about after the 4th comboBox.
Apparently there is another item being focused, however, I have checked the
tab index value on each of my items and they are all set in consecutive
numerical order.

I thought a good way of troubleshooting this would be to obtain the object
name that has focus. How can I do this? I looked on Google, but there
seemed to be only references of setting the focus and not retreiving the
name.

Something like this maybe?

MessageBox.Show(this.ItemThatIsFocused.ToString());
 
Hi Keith,

You can iterate thought the Controls collection of your form, check if the
control has focus and display the name of the control.

foreach (Control cnt in this.Controls)
{
if ( cnt.Focused )
MessageBox.Show (cnt.Name);
}


Hope this helps.
 
Back
Top