When I start my project WinForms
I set focus on a lookUp Edit
component of DevExpress
that has a Leave
event. The purpose of this focus is to make target selection compulsory. The initial value of this component is null
and is populated with bank data. When clicking on another element, for example: a menu that is in the main form, an alert is displayed but it is looped. I need that after clicking on another element, the alert is displayed and the focus goes back to lookup Edit destino
.
In my opinion, the loop happens because the default value of the destination is = null
and after return
it ends up falling in the same condition. But I could not find a way to fix this.
The default value of the Encerrar é false
variable and the default value of the destino é null
component
How can I resolve this? Below is a snippet of code.
private void Destino_Leave(object sender, EventArgs e)
{
if (!Encerrar)
{
if (destino.EditValue == null)
{
MessageBox.Show("Selecione um Destino");
ActiveControl = destino;
destino.Focus();
return;
}
LugarDestino = destino.EditValue.ToString();
...restante do código...
}
}