如何在该按钮被禁用后删除按钮焦点。 [英] How to remove button focus after that button get disable.

查看:63
本文介绍了如何在该按钮被禁用后删除按钮焦点。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表格上有3个按钮,b1,b2,b3。

B2& B3是禁用的。当我们点击按钮b1时,它启用按钮b2。

当我们点击按钮b2时,b2get disble&按钮b3启用。

Buttob按钮b2仍然是焦点。



我如何将焦点从b2更改为b3。



我尝试了什么:



我曾尝试更改标签索引。

b1.TabIndex = 0;

b2.TabIndex = 2;

b3.TabIndex = 3;

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;

推荐答案

单独保留tabIndex - 它只影响用户按下TAB键时访问控件的顺序。

在Click事件处理程序中:

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();
    }


这篇关于如何在该按钮被禁用后删除按钮焦点。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆