Reputation: 4261
I have 2 constructors in my class:
public partial class Fiche_Ordre : Le_MainForm
{
public Fiche_Ordre()
{
InitializeComponent();
Constuct_Page();
}
public Fiche_Ordre(string OrderID): this()
{
Pers_Ordre oPersOrdr = oOrder_BL.Get_OrdreOne_BL(ClientID, Convert.ToInt32(OrderID), false);
textEdit_RefExpred.Text = oPersOrdr.RefExpd;
lookUpEdit_Agence.EditValue = oPersOrdr.Agence;
lookUpEdit_Transport.EditValue = oPersOrdr.Transporteur;
lookUpEdit_Dest.EditValue = oPersOrdr.DestId;
..................
}
public void Constuct_Page()
{
try
{
ClientID = Program.Le_ClientID;
....
#region LookUpEdidt Destinataire
lookUpEdit_Dest.Properties.DataSource = Auxiliaire_BL.FillCombo_BL(false, ClientID).Tables["ComboFill"];
lookUpEdit_Dest.Properties.ValueMember = "CODE_DEST";
lookUpEdit_Dest.Properties.DisplayMember = "CODE_DEST";
LookUpColumnInfoCollection coll_Dest = lookUpEdit_Dest.Properties.Columns;
// A column to display the ProductID field's values.
coll_Dest.Add(new LookUpColumnInfo("CODE_DEST", 0, "Code Destinataire"));
// A column to display the ProductName field's values.
coll_Dest.Add(new LookUpColumnInfo("RS_NOM", 0, "Raison Social"));
// Set column widths according to their contents and resize the popup, if required.
lookUpEdit_Dest.Properties.BestFitMode = BestFitMode.BestFitResizePopup;
// Enable auto completion search mode.
lookUpEdit_Dest.Properties.SearchMode = SearchMode.AutoComplete;
// Specify the column against which to perform the search.
lookUpEdit_Dest.Properties.AutoSearchColumnIndex = 1;
lookUpEdit_Dest.EditValueChanged += new EventHandler(lookUpEdit_Dest_EditValueChanged);
#endregion
...
}
It is strange, because when I use public Fiche_Ordre()
it does not fire new EventHandler(lookUpEdit_Dest_EditValueChanged);
; but when I use public Fiche_Ordre(string OrderID)
, it does fire the event handler.
Is this normal or not?
the first constuctor it call from Main form
public partial class Le_MainForm : DevExpress.XtraEditors.XtraForm
{
public Le_MainForm()
{
InitializeComponent();
this.Name = "MainUSER";
if (Program.IsFA) barButtonItem_OrdList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
}
private void barButtonItem_CreatOrdreAller_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
Close_AllForm();
Program.AllerRetour = "Ordre Aller";
Fiche_Ordre f_Fiche = new Fiche_Ordre();
f_Fiche.Show();
}
and the second constructor i call it from
public partial class Liste_Ordres : Le_MainForm
{
private void Liste_DobleClic(object sender, EventArgs e)
{
try
{
Program.OrderId = gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString();
this.Hide();
Fiche_Ordre f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
f_Fiche.Show();
}
catch (Exception excThrown)
{
MessageBox.Show(excThrown.Message);
}
}
Thank you in advance.
PS: the first constructor is just to create the NEW blank page, and the second constructor is to create NOT NEW (Edit page), so i passed the id and fill all control (textbox, memo, etc...)
Upvotes: 0
Views: 915
Reputation: 12521
The EditValueChanged
handles is wired in the very last line of Constuct_Page
. Therefore it fires only for changes after Constuct_Page
. Is it changed in the ..................
part of the code? It does sound like an over-simplified speculation, but it's worth double-checking anyway...
Besides, may I suggest you another improvement:
public Fiche_Ordre(string OrderID) : this.Fiche_Ordre()
{
// invokes the other constructor first, so they're guaranteed
// do be equivalent in the first part
Pers_Ordre oPersOrdr = oOrder_BL.Get_OrdreOne_BL(ClientID,
Convert.ToInt32(OrderID), false);
// ...
}
Upvotes: 1
Reputation: 2760
Put breakpoint and look on to lookUpEdit_Dest when you want bind eventhandler, i think that this var doesn't initialize, so you need to add initialize from second constructor to first.
Upvotes: 0