我正在使用winforms,並且我試圖在設計器中顯示form \ component \ usercontrol的任何時間在某些事件中鏈接,我是試圖鏈接一些從app.config文件加載首選項的靜態事件。Winforms - 當任何表單被加載到設計器中時執行一個函數
是否可以在我的項目中定義代碼,說「任何時候控件加載,執行此事件?」
編輯這是嚴格的設計時間的事情。
我有一個基本形式,在DLL「A」。這有很多屬性,「ColorLocation,SizeLocation」和這種性質的東西。
在DLL「B」中我有一個派生形式。當B被加載到設計器中時,我有iEditorComponents(不記得確切的名字),它允許用戶從當前項目的app.config設置文件中指定的大量項目中選擇ColorLocation。
問題是,編輯組件位於Dll「A」,它是基礎,它無法訪問「B」中的app.config。
我需要一些辦法來告訴編輯組件「嘿,使用這個字符串列表填充您的編輯控件」。設計師正在盡其所能,似乎不想在派生類中執行任何代碼。
這聽起來不太好。設計時間遠離運行時間。首先,沒有好方法來訪問項目的app.config文件。另一方面,有可能有人聽到這個事件應該是零。 – 2012-04-03 16:46:58
你能解釋一下你的用例嗎?你的意思是你想在包含表單加載時在你的組件中執行一些代碼嗎? – 2012-04-03 18:09:47
另外,這是一個設計時間或運行時間的事情? – 2012-04-03 18:14:25