Silly Windows Forms Question

  • Thread starter Thread starter kalantre
  • Start date Start date
K

kalantre

Hello,

I have a Windows form that displays some data from a database. The only
two controls worth talking about are one ComboBox and one Rich Text Control.

When I show the dialog, the focus goes straight to the ComboBox. I set a
txtBox.Focus() for the FormLoad but that doesn't do the job...

Could you please help me out?

Thanks,
Kalantre
 
Hi kalantre,

If you have Visual Studio you can specify the tab order in one of the
menus.
I forget which one and can't check it right now.
If you don't have Visual Studio, simply make sure that you add the textbox
to
this.Controls.Add();
before you add the ComboBox.

Hope this helps,
Morten
 
Hi Morten,

Thank you for your quick response.

I am using Visual Studio. I changed the TabIndex of all controls -
making the textbox index 2 and combobox index 1, and the other way
around. Whatever I do, the ComboBox gets the focus.

Could the fact that both these controls sit on two separate panels make
any difference?

Thanks again,
Kalantre
 
Hi kalantre,

yes, separate panels would have everything to do with it. You need to set
the tab order for the top level controls first.
It should be something like:

TextBoxPanel - [0]
TextBox - [0,0]

ComboBoxPanel - [1]
ComboBox - [1,0]

Hope this helps,
Morten
 
Back
Top