Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using the Binding source in my winform C# application.
I had no problems with other Forms and Tables.
But now i can't solve my problem:
My Binding is :
BindingSource BS_ART = new BindingSource(Parametres.DS_GESPI, "ARTs");
the BS_ART.CancelEdit() doesn't work after the controls bindings. When I test it before the Create Void, it's well working. But I' can't understand.
The bindings to my controls is:
I'm using a usercontrol named TextBoxCalcul where there is into it a TextBox named TEXTBOX_AVEC_CALCULATRICE.

C#
private void CreateBindingsART()
{
 
    FarttxtID.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_ART"].ToString()));
    FarttxtCODE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["CODE_ART"].ToString()));
    FarttxtDESIGNATION.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["DESIGNATION_ART"].ToString()));
    FarttxtREF_FOURNISSEUR.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["REF_FOURNISSEUR_ART"].ToString()));
    FarttxtPAQUET.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["PAQUET_ART"].ToString()));
    FarttxtCOMMENTAIRES.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["COMMENTAIRES_ART"].ToString()));
    FarttxtDOUANE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["DOUANE_ART"].ToString()));
    FarttxtPRIX_ACHAT.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["PRIX_ACHAT_ART"].ToString()));
    FarttxtV1.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["CONSOMMATION_AN_ART"].ToString()));
    FarttxtV2.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["COUT_COMMANDE_ART"].ToString()));
    FarttxtV3.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["PRIX_ACHAT_ART"].ToString()));
    FarttxtV4.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["COUT_POSSESSION_ART"].ToString()));
    FarttxtV5.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["DELAI_ART"].ToString()));
    FarttxtV6.TEXTBOX_AVEC_CALULATRICE.DataBindings.Add(new Binding("Text", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["PROTECTION_ART"].ToString()));
    FartcheckBoxGERER.DataBindings.Add(new Binding("Checked", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["GERER_ART"].ToString()));
    FartcheckBoxACTIF.DataBindings.Add(new Binding("Checked", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ACTIF_ART"].ToString()));
    FartMCCBfou.DataBindings.Add(new Binding("SelectedValue", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_FOU"].ToString()));
    FartMCCBdoc.DataBindings.Add(new Binding("SelectedValue", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_DOC"].ToString()));
    FartMCCBcat.DataBindings.Add(new Binding("SelectedValue", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_CAT"].ToString()));
    FartMCCBuni.DataBindings.Add(new Binding("SelectedValue", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_UNI"].ToString()));
    FartMCCBcri.DataBindings.Add(new Binding("SelectedValue", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_CRI"].ToString()));
    FartMCCBmet.DataBindings.Add(new Binding("SelectedValue", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ID_MET"].ToString()));
}
Posted
Updated 15-Nov-13 3:46am
v5

1 solution

I found the solution:
For the bindings on Checkboxes we have to add:
, true, DataSourceUpdateMode.Never));
Example:

FartcheckBoxACTIF.DataBindings.Add(new Binding("Checked", BS_ART, Parametres.DS_GESPI.Tables["ARTs"].Columns["ACTIF_ART"].ToString(), true, DataSourceUpdateMode.Never));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900