Tab Order in VB .NET Windows Form

I have a Smart Device Application for a CE Device and whenever I hit Tab Order on the main Form I get an error 'Invalid Cast Exception'. The Form only has three buttons, a checkbox and a progress bar.
I don't know if it's related (perhaps my .NET Installation is screwed) but whenever I select help, I get a message saying 'Help is updating to reflect your recent changes. This may take several minutes.', followed by server execution failed.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Yeah, this doesn't sound good.  I haven't seen this error before.  Did you just install something new?  How long has it been running without error?  Operating System (XP)?  Did you install XP Service Pack 2, and then it started crapping out?

Tab Order and Focus

The .NET Compact Framework supports tabbing between controls with Service Pack 2 and later, but requires that you explicitly use the Focus method on the first control that should receive the focus.

The .NET Compact Framework does not support the TabIndex and TabStop properties or the UpdateZOrder method, but you can design your application to have a predictable tab order and explicitly set controls to receive focus. The up and down navigation follows the tab order.

The default tab order follows the sequence of focusable controls as they are added in code to the Controls collection.

Note that the forms designer creates the Controls collection in reverse order of when the controls were added to the form. For example, if TextBox1, TextBox2, and TextBox3 are added to the form in that order, then first control in the Controls collection is TextBox3. The following Visual Basic example shows designer-generated code in the InitializeComponent method of a form.


To fix the Controls collection so that the tab order starts with TextBox1 as the first focused control, followed by TextBox2 and then TextBox3, use the Focus method on TextBox1 and rearrange the code as follows:


You can control tab order by doing one or more of the following:

    * Arrange the sequence of controls in the Controls collection.
    * Use the Focus method.
    * Use BringToFront and SendToBack methods.

If you are creating a custom control, set the Enabled property to true if you want it to receive focus. You can also specify which control next receives the focus in a method that handles the KeyPress or KeyDown events.

The following controls are focusable and support tabbing in the .NET Compact Framework:

    * Button
    * ListBox
    * HScrollBar
    * VScrollBar
    * ComboBox
    * CheckBox
    * RadioButton
    * TextBox
    * Tab
    * TabPage
    * NumericUpDown
    * DomainUpDown
    * TrackBar
    * ListView
    * TreeView

    Note   Pocket PC applications do not display focus rectangles around controls that have the focus.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VFPSQLDeveloperAuthor Commented:
Hi Bob,

It's windows 2000 Pro. I have installed some new stuff (unrelated to VB .NET) but I haven't tried the Tab Order so I don't know if these screwed it or not. I did re-install the MSDN which fixed the help problem.
VFPSQLDeveloperAuthor Commented:
Thanks Mikal613, it's not a huge app so re-arranging  InitializeComponent code works just fine.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.