是否可以设置一个按钮,只有在bool为真时才可以点击? 这不是我的实际代码,但是:
bool details_accepted = false;
public bool check_bank_details()
{
//this is simplified it's actually using an SQL query
if (bank_details = "123456789")
{
return true;
}
else
{
return false;
}
}
if (check_bank_details == true)
{
//CODE FOR SETTING BUTTON TO CLICKABLE
}
else if (check_bank_details == false)
{
//Code making Button not clickable
}
答案 0 :(得分:1)
使用Enabled属性
Button1.Enabled = check_bank_details();