C# Winform event handler

I have 2 constructors in my class:

public partial class Fiche_Ordre : Le_MainForm
         public Fiche_Ordre()

              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()
                      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);

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()

            this.Name = "MainUSER";

            if (Program.IsFA) barButtonItem_OrdList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;


 private void barButtonItem_CreatOrdreAller_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
            Program.AllerRetour = "Ordre Aller";
            Fiche_Ordre f_Fiche = new Fiche_Ordre();


and the second constructor i call it from

public partial class Liste_Ordres : Le_MainForm

     private void Liste_DobleClic(object sender, EventArgs e)
                    Program.OrderId = gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString();
                    Fiche_Ordre f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
                catch (Exception excThrown)

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...)


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);

  // ...

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.

instead create Constuct_Page(); just put in Form_Load()

Need Your Help

TopLink EntityManager doesn't save object properly

java java-ee jpa toplink

Really appreciate ANY help (at least ways how to trace root cause of the problem) because I've been fighting with this for several days and didn't find even workaround.

AJAX load a dynamic page into a div

javascript jquery ajax wordpress

A client needs the url to stay the same on a wordpress website.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.