Preventing a control from receiving focus when usi

2019-06-14 05:00发布

问题:

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.

回答1:

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



回答2:

If this is Winforms, you set the TabStop property to false.



回答3:

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.



标签: c# controls