1
Boa noite Galera,
I have a problem in a project in c# where I need to navigate in a bindingSource and fill the form fields with the values referring to the position of the bindingSource, i’ve already filled it all right problem ta when I go to the next record it from the error in the textbox saying that already has association follow the message "this generates two associations in the collection to link to the same property", below follows the code
private void btnProximo_Click(object sender, EventArgs e)
{
if (bindingSourcePais.Position + 1 < bindingSourcePais.Count)
{
try
{
proximo();
}
catch (Exception ex)
{
Util_Msg.erro(ex.Message);
}
}
}
private void proximo()
{
bindingSourcePais.MoveNext();
txtCodigo.DataBindings.Add("Text", bindingSourcePais, "codigo");
txtNome.DataBindings.Add("Text", bindingSourcePais, "nome");
}
Take the code from the
DataBindings.Add
from within the method you perform every time you click the button. You just need to associate the control with thebindingSource
once– Rovann Linhalis
Good evening @Rovannlinhalis, it worked your tip, I did not know this detail thank you
– Luiz Fernando