Disable Toolstripbutton in Form

Asked

Viewed 55 times

0

I need to do a check and if it is true, the button remains enabled, if it is false, the button must be disabled...

How could I do that ?

So far only have the if, because I do not know how to do this:

if(true)
{
    //aqui faz minha verificações
}
else
{
   //aqui faria com que o botão fosse desabilitado 
}

Is there any easy way to do that? Someone could help me ?

2 answers

1


Érik

if(true)
{
    // Habilita
    meuStripButton.Enabled = true;

    // Exibe
    meuStripButton.Available = true;
}
else
{
     // Faz botão ficar cinza (disable)
     meuStripButton.Enabled = false;

     // Faz botão sumir (hide)
     meuStripButton.Available = false;
}

1

The most summarized and reusable way you could do this is as follows:

var condicao = //minha condicao    
meuStripButton.Enabled = condicao;
meuStripButton.Available = condicao;

if(condicao)
{
//aqui faz suas verificações
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.