[英]C#, WinForm: cannot set designer-created-control with code-created control
[英]ImageList created in Designer - Where is the code?
不久前,我使用Designer為ListView
創建了一個ImageList
。 現在我正在尋找那些圖像和控制ImageList
但無法找到它的代碼。 “ 查找所有引用 ”並未顯示所有引用 (我認為它將在InitializeComponent
)。
我可以使用Designer來設置ImageSize
,但無法在代碼中的任何位置找到它。 不僅如此 - 但如果我在調用InitializeComponent
后手動添加它 - 圖像在運行時消失。
我無法在解決方案資源管理器中的任何位置找到圖像。
要清楚 - 圖像確實在運行時顯示。
將資源添加到表單( ImageList
,表單Icon
等)時,它將保存在表單資源(resx-file)中。
它們會自動加載到InitializeComponent()
方法中,該方法在表單構造函數中調用。
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
...
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
...
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.