Click here to Skip to main content
15,898,978 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using a simple form with two comboboxes and two textboxes I am entering data in the textboxes called options and cost.

The two comboboxes contain text from a database and I simply select what I want and then start entering options and their cost.

Below the textboxes I have a datagridview that displays the text selected from the comboboxes and entered in the text boxes when I press the enter key while in the cost textbox. All of this works fine and have no problems. The problem occurs that after I press enter on the cost box, the cursor stays in the cost box and I have to use the mouse to move back up to the option textbox.

Is there any way to do this programmatically?

What I have tried:

Tried using a TableLayoutPanel without success. Never figured out how to select the cell that contains the options textbox.

The goto statement is equally useless.
Posted
Updated 17-May-20 15:08pm

1 solution

Well, you can set the Tab Order of the controls - Set tab order of controls - Windows Forms | Microsoft Docs[^] - and to start at a particular control iirc by someControl.Select() - (.Focus() likely wont work depending on where you do this, ie, the form/control needs to be visible)

Hope this helps
 
Share this answer
 
Comments
Member 14810577 17-May-20 21:58pm    
<textboxname>.Focus is exactly the command I have been trying to find. Thanks!
BillWoodruff 19-May-20 2:10am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900