Preventing a control from receiving focus when usi

2019-06-14 04:11发布

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.

标签: c# controls
3条回答
戒情不戒烟
2楼-- · 2019-06-14 04:57

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

查看更多
我命由我不由天
3楼-- · 2019-06-14 05:00

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

查看更多
够拽才男人
4楼-- · 2019-06-14 05:12

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.

查看更多
登录 后发表回答