Tab Order in VB .NET Windows Form

Posted on 2004-12-01
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
    LVL 96

    Expert Comment

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

    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

    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

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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    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 (…
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now