Silly Windows Forms Question

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
 
M

Morten Wennevik

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
 
K

kalantre

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
 
M

Morten Wennevik

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
 

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

Top