Click here to Skip to main content
15,904,823 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
On form there are 3 button , b1,b2,b3.
B2 & B3 are disable.When we clicks on the button b1 it enable the button b2.
When we click on the button b2 , b2get disble & button b3 get enable.
Buttob button b2 had still focus.

How i change focus from b2 to b3.

What I have tried:

I had tried to change tab index.
b1.TabIndex = 0;
b2.TabIndex = 2;
b3.TabIndex = 3;
Posted
Updated 29-Aug-18 20:15pm
Comments
MarqW 30-Aug-18 1:51am    
Are you sure? Because disabled controls can't have focus.
But you can just do "b3.Focus();"

1 solution

Leave the tabIndex alone - it only affects the order in which controls are "visited" when the user presses the TAB key.
In the Click event handlers:
private void B1_Click(object sender, EventArgs ew)
    {
    B1.Enabled = false;
    B2.Enabled = true;
    B3.Enabled = false;
    B2.Focus();
    }
private void B2_Click(object sender, EventArgs ew)
    {
    B1.Enabled = false;
    B2.Enabled = false;
    B3.Enabled = true;
    B3.Focus();
    }
private void B3_Click(object sender, EventArgs ew)
    {
    B1.Enabled = true;
    B2.Enabled = false;
    B3.Enabled = false;
    B1.Focus();
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900