我的班级有 2 个构造函数:
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
...
}
这很奇怪,因为当我使用public Fiche_Ordre()
它时它不会触发new EventHandler(lookUpEdit_Dest_EditValueChanged);
;但是当我使用时public Fiche_Ordre(string OrderID)
,它会触发事件处理程序。
这是正常的还是不正常的?
它从主窗体调用的第一个构造函数
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();
}
我调用它的第二个构造函数
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);
}
}
先感谢您。
PS:第一个构造函数只是创建NEW空白页面,第二个构造函数是创建NOT NEW(编辑页面),所以我传递了id并填充了所有控件(文本框,备忘录等......)