在此處輸入代碼我已經基於兩個baseform,一個帶有網格(_ListForm)的列表窗體和一個顯示子數據(_DataForm)的數據窗體構建了一個winform MDI應用程序。Baseform中的激活事件不會觸發
當我將一個繼承的數據表單加載到MDI中時,來自基本形式(_DataForm)的激活事件被觸發並且一些屬性被自動設置。當我將一個繼承的listform(_ListForm)加載到MDI中時,激活的事件是而不是被觸發。
我的childform沒有(overrided)激活的事件,兩種形式沒有明顯的區別,只有一個觸發事件,一個沒有。
- 我已在代碼中的事件處理程序和/或與設計師沒有 觸發
- 我在childform增加了一個新激活的事件,並呼籲 base.onActivated(E):無觸發
現在我把一些代碼移到了textchanged事件中(這也會出現一次),但爲什麼這個Activated-event沒有被觸發?
如果需要可以添加大量的代碼示例,但不知道要發佈什麼。
編輯:忘了提,它與LoadEvent一樣 - 不會以任何方式觸發。
編輯:源頭按請求:
_BaseForm:字體和一般背景(無事件)
public partial class _BaseForm : Form
{
public _BaseForm()
{
InitializeComponent();
}
_ListForm:網格和按鈕
public partial class _ListForm : _BaseForm
{
public _ListForm()
{
InitializeComponent();
this.Activated += new EventHandler(_ListForm_Activated);
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.grid1.UltraGrid.DisplayLayout.Bands[0].Columns.ClearUnbound();
this.grid1.UltraGrid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
this.grid1.UltraGrid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
this.grid1.UltraGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
this.grid1.UltraGrid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
this.grid1.PopulateGridColumns += new FB.Windows.Controls.Grid.PopulateGridColumnsEventHandler(grid1_PopulateGridColumns);
this.grid1.UltraGrid.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(UltraGrid_InitializeLayout);
this.grid1.RowSelected += new FB.Windows.Controls.Grid.RowSelectedEventHandler(grid1_RowSelected);
}
_ListForm事件(在設計者或來自ctor的代碼):
this.Activated += new System.EventHandler(this._ListForm_Activated);
this.Load += new System.EventHandler(this._ListForm_Load);
事件本身:
private void _ListForm_Activated(object sender, EventArgs e)
{
if (AutoSearchOnOpen)
{
button1_Click(sender, e);
this.grid1.Focus();
this.ActiveControl = this.grid1;
}
else
{
this.textBox1.Focus();
this.ActiveControl = this.textBox1;
}
}
我知道點擊激活的事件會在每次啓動時將火裏,但現在這並不重要:主要問題是:整個事件不會火。儘管在_DataForm(也繼承自_BaseForm)的事件是發射。
你的MDI孩子的確切類型是什麼?我們還可以看到您提及的事件的代碼以及將它們連接起來的代碼。 – 2012-03-30 17:38:40
你是什麼意思的類型? PS source-samples在代碼和設計器中顯示激活的事件 - 但實際上只有一個 - 我在設計器中綁定事件(並評論代碼),或者將事件綁定到代碼中並刪除設計器-bind。 – riffnl 2012-04-02 11:54:36
你有代碼示例應該工作(很高興看到你的InitializeComponent方法)。在這一點上,我認爲你應該備份你的_ListForm文件,然後註釋掉所有的網格和額外的代碼,這樣你只剩下一個空的_ListForm,看看是否觸發你的事件。如果是這樣,請慢慢回覆評論。 – 2012-04-02 14:21:34