0
I have a datagrid with records and an edit button. At the moment I am doing the following: the user selects the Datagrid item and clicks the Edit button, to then be performed the verification whether or not he can edit the record. I would like to disable the button as soon as the item was selected in Datagrid, without having to click the button to be warned that it cannot edit.
private void btnEditar_Click(object sender, RoutedEventArgs e)
{
if (dataGrid.SelectedItem != null)
{
if (Presenter.PodeEditar())
{
chamaMetodoEdicao();
}
else
MessageBox.Show("Impossível editar!");
}
else
MessageBox.Show("Selecione um item.");
}
Do you want to disable the button when any row is selected? Or do you want to do some validation according to the contents of a specific cell? Post the code you made to the button to validate whether or not it can edit the record.
– Jéf Bueno
Exactly, I want to do the validation according to the contents of the selected cell. I will edit the question.
– Mathi901
By the way, your project is
Windows Forms
orWPF
?– Jéf Bueno
My project is WPF
– Mathi901
You have to use the tag
WPF
. I edited it for you. I’ll change the answer.– Jéf Bueno