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.
 

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

Similar Threads

Setting focus 2
Undo ComboBox Dropdown? 4
Please give me back the focus for my mouse wheel (VS 2010-Testversion) 1
Focusing a TextBox 4
combobox.focus in a datagrid. 2
Disappearing Toolstrips 4
Windows 10 Itunes/TabKey 0
listbox focus 1

Back
Top