BindingSource CancelEdit问题 [英] BindingSource CancelEdit Problem
问题描述
我在winform C#应用程序中使用了绑定源。
我对其他表格和表格没有任何问题。
但现在我无法解决我的问题问题:
My Binding是:
BindingSource BS_ART = new BindingSource(Parametres.DS_GESPI,ARTs);
BS_ART.CancelEdit( )在控件绑定后不起作用。当我在Create Void之前测试它时,它运行良好。但是我无法理解。
我的控件的绑定是:
我正在使用一个名为TextBoxCalcul的用户控件,其中有一个名为TEXTBOX_AVEC_CALCULATRICE的TextBox。 br $>
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.
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()));
}
推荐答案
我找到了解决方案:
对于Checkboxes上的绑定,我们必须添加:
,true,DataSourceUpdateMode.Never));
示例:
FartcheckBoxACTIF.DataBindings.Add (new Binding(Checked,BS_ART,Parametres.DS_GESPI.Tables [ARTs]。Columns [ACTIF_ART]。ToString(),true,DataSourceUpdateMode.Never));
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));
这篇关于BindingSource CancelEdit问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!