Dumbo
Dumbo

Reputation: 14142

Changing TabIndex when a control gets disabled

In my c# winforms application, I have two buttons named left and right which they go through some values.

When data reaches end, right button is getting disabled. As soon as left button is clicked right button gets enabled again and same for beggining of the data.

The problem is, If I reach the end and right is disabled, the TabIndex jumps to next control in the form. But I want it to jump to the pervious TabIndex which is the left button.

I have tried the Focus() Method. It works, but I literally want it like the user has pressed the TAB key to get there (I mean the dash line around the control).

Any ideas?

Upvotes: 0

Views: 1411

Answers (2)

foowtf
foowtf

Reputation: 399

Try the Select() method. You can pass two arguments specifying whether a preceding or following control in tab order should be selected.

http://msdn.microsoft.com/en-us/library/hb97bya5.aspx

Upvotes: 1

prema
prema

Reputation: 427

First check whether right button is disabled or not. If right button is disabled, then make the left button .focus() Unless you post your sample code or something, it is difficult to answer more than this

Upvotes: 0

Related Questions