简体   繁体   中英

Preventing a control from receiving focus when using the Tab key

How does one set a TextBox control so that it has no TabIndex at all.

I want to make it so that the user can't tab into it.

[explanation]
The reason I asked this question is because I recently switched from vb to c#, and am trying out the QuickSharp SDK. If you use that system, then you have to build your forms without Visual Studio's visual designer - hence, there is no GUI to help you in setting all the properties of the form. It's a good learning experience, however.

So, it may seem a trivial question, but under the circumstances, I think it is a legitimate question.

According to MSDN : For a control to be included in the tab order, its TabStop property must be set to true.

So setting the TabStop property to false should remove it from the TabOrder

如果这是Winforms,则将TabStop属性设置为false。

If you are using Winforms then you can use Control.TabStop Property

button1.TabStop = false;

For asp, you can also use tabindex="-1".

The W3C HTML5 supports negative tabindex values: The summary of above documentation is

If the value is a negative integer,The user agent must set the element's tabindex focus flag, but should not allow the element to be reached using sequential focus navigation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM