How to Set Up Winform Textbox Field Focus so a User Can Go Through Them by Clicking Tab Button?

元气小坏坏 提交于 2019-12-11 05:27:12

问题


UI is created in VS 2008. I'm using C# .... I need to let the user move/focus between text fields from top to bottom by clicking tab button. How can i do it?


回答1:


You just set up the TabIndex property properly, so that it's sequential from top to bottom. Then it'll work automatically and you won't need any code to move around the focus.

So in other words, set the top TextBox TabIndex to 1, the next one you set to 2 etc and then one at the bottom will have the highest number (of the textboxes, you probably want to have even higher indexes for any OK buttons and similar so that the user can jump to them after editing all the textboxes).

You can find more info about it here:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabindex.aspx




回答2:


On the Layout toolbar (will normally show up if you're in Design View) click on the buttom on the most right (it's called tab order).

Now on every element on your designer will come up a little box with a number. Just click all your elements in the order you like and they will automatically be re-ordered.

If you like to do it manually, just take ho1 advice and change the property manually.



来源:https://stackoverflow.com/questions/2942617/how-to-set-up-winform-textbox-field-focus-so-a-user-can-go-through-them-by-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!