AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Stephen Jackson
Expertise
I can help with questions regarding VB.NET syntax and object references, with data interfaces and with the design and creation of robust, data aware object classes. I can also be very helpful with creating distributable applications and provide tricks and tips on .msi creation. I also have extensive experience in designing SQL Server Databases and interfacing them with VB.NET. I try to avoid web specific questions, as that is an area of expertise all its own.

Experience

Experience in the Area:
I have been a programmer in Visual Basic since version 1.0 and have worked with VB.NET (which is infinitely more powerful than previous versions) since its initial release and SQL Server, both as a corporate IT professional and professional consultant. I first wrote Basic in 1976 on a TRS 80 and have worked in Visual Basic 1.0 and every subsequent release of Microsoft Visual Basic. I worked for over 7 years as a Senior Level Consultant in the area and currently hold a Project Manager position in IT.

Education and Credentials:
MBA in Econometrics, 1983, University of Memphis. BBA in Financial Management, 1982, Fogelman College of Business and Economics, University of Memphis.
Microsoft Certified Professional

Areas of Special Expertise:
My specialty is the design of Object Oriented Solutions with robust, data aware object classes. I generally avoid the classic ‘Three Tier’ model as I find it redundant and cumbersome to maintain. I also specialize in the creation of ‘User Friendly’ User Interfaces which help lessen the need for user training and help prevent user error. I work best with Windows Forms based applications, and while I do work in C# as well, I prefer to limit my questions here to Windows Forms based applications created in Visual Basic.NET and SQL Server. I wil also address questions relating to the distribution and installation of Windows Forms based applications created in VB.NET.
 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > Next Control

Topic: VB.NET



Expert: Stephen Jackson
Date: 4/28/2008
Subject: Next Control

Question
Good day. I am a beginner.

How can I write a code that will automatically go to the next control?

I got a three TextBox on a form. When I press the Enter key the focus must be on the next Textbox and so on..

I use the SelectNextControl( ? , true, true, true, true) but I don't know what value to be passed on the first parameter. My form is set to Keypreview = true.

And How can I set the Key Value of the pressed Key? I mean if I press Enter the value key value would be a Tab Key. Like this if (KeyPressed = Enter Key) then Keypressed = Tabk Key.

Thank you very much.  

Answer
Lloyd,

I am not sure you will have much luck with the approach.  Windows Forms are designed to accept the enter key more as a form level command (for example, to activate the control set as default, often a button).  The tab key is the navigation key.  I tried several variants on this and the only one which gave me any success at all was to us this:

   Private Sub TextBox1_KeyDown(ByVal sender As Object, _
       ByVal e As System.Windows.Forms.KeyEventArgs) Handles
       TextBox1.KeyDown

       If e.KeyCode = Keys.Return Then
           SelectNextControl(TextBox1, True, True, True, True)
       End If

   End Sub

Note that the first argument should be the control which is one step below the control you want to go to in the tab order.  Even though this works it 'beeps'.  Windows does not like this usage at all.  Changing the argument to a tab simply will not work.

I hope this  helps, at least!

Thanks,

Stephen Jackson

View Follow-Ups    Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.