ComboBox - start with focus?

  • Thread starter Thread starter Ed Stewart
  • Start date Start date
E

Ed Stewart

Hello. I first posted this on microsoft.public.dotnet.languages.csharp
because I found that linked to on some website. Since then, I've found this
windowsforms group. Sorry if you're reading this twice; it won't happen
again.

I'm creating an application that requires user input into a ComboBox, and
I'd like to have the cursor appear in this emtpy ComboBox when the
application starts. I had a plain TextBox, and the cursor started there
automatically; to implement a history feature, I've moved to a ComboBox, but
now the user needs to click on it before typing.

How do I set focus on this item? I've tried adding a null string and calling
comboBox.Focus() to no avail. I read somewhere the trick is to set the focus
to the editable text box contained within the ComboBox, but I haven't been
able to figure out how to do that.

Thanks,
-ed
 
Ed Stewart said:
I'm creating an application that requires user input into a ComboBox, and
I'd like to have the cursor appear in this emtpy ComboBox when the
application starts. I had a plain TextBox, and the cursor started there
automatically; to implement a history feature, I've moved to a ComboBox, but
now the user needs to click on it before typing.

How do I set focus on this item? I've tried adding a null string and calling
comboBox.Focus() to no avail. I read somewhere the trick is to set the focus
to the editable text box contained within the ComboBox, but I haven't been
able to figure out how to do that.

Are there other controls on form? If so, what is the TabIndex of the
ComboBox? Typically the first control in the tab order of a dialog should
get focus when the dialog is displayed. In your form's Design view, click
View->Tab Order to see the overall tab order.
 
Are there other controls on form? If so, what is the TabIndex of the
ComboBox? Typically the first control in the tab order of a dialog should
get focus when the dialog is displayed. In your form's Design view, click
View->Tab Order to see the overall tab order.

There are a lot of other items in the form, and I never would have thought
of the Tab Order (I thought this was just a navigation control). I set the
ComboBox to 0 and now the cursor is right there when it starts up.

Thanks a lot,
-ed
 
Back
Top