Problem with TextBox.Focus (). Repeats SQL when giving focus in field

0

I have a function that writes some information to a table when exiting a TextBox (Leave). However, when exiting, the focus returns to the first TextBox . When this occurs it directs the focus as it should, but reinsert the row in the database with the same information (doubles). What can I do to adjust?

I'm doing it this way:

public void InsereDados()
    {
        //Pega o valor dos campos e insere no banco
    }

    public void AtualizaGrid()
    {
        //Atualiza as informações no Grid        
    }

    private void Tbnome_Leave(object sender, EventArgs e)
    {          
            InsereDados();
            AtualizaGrid();
            //Volta o Foco para o Primeiro TextBox
            TbCod.Focus();           

    }
    
asked by anonymous 12.07.2018 / 05:51

0 answers