Tab Order in VB .NET Windows Form

Posted on 2004-12-01
Medium Priority
Last Modified: 2011-10-03
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.
Question by:VFPSQLDeveloper
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 12716500
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?

LVL 48

Accepted Solution

Mikal613 earned 2000 total points
ID: 12716632
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.

Author Comment

ID: 12717464
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.

Author Comment

ID: 12718116
Thanks Mikal613, it's not a huge app so re-arranging  InitializeComponent code works just fine.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question