How do I disable a tab index on a control on a form?

Just set the TabStop property of the Labels to false and the TabIndex property of the Buttons to whatever you want. You can do it right in the Properties window of the designer.


button1.TabIndex = 0;
button2.TabIndex = 1;

Labels by default have TabStop set to false which means they shouldn't get focus by pressing tab.


In my case, all my Labels don't have TabStop property.

I cannot even set the TabIndex to -1 either, since it will say Property value not valid.

But I notice that once I run the application, regardless on what value I have on my TabIndex for all my labels, it doesn't stop on any labels when I press my Tab on my keyboard.

The reason for this is that Label controls do not get focus. The only way to cause a Label control to gain focus is to call the Label.Focus method.

For more info, you can read this forum: MSDN Forum.

Tags:

C#

Tabindex