2008-09-18 97 views
0

我想爲C#WinForms TreeList控件製作狀態圖標。狀態是其他狀態的組合(例如,用戶節點可能處於不活動狀態或被禁止狀態,或者處於非活動狀態並被禁止),狀態圖標由非重疊的小字形組成。如何從較小的組件圖像構建C#ImageList圖像?

我真的想避免手動生成所有可能的狀態圖標排列,如果我可以避免它。

是否有可能創建一個圖像列表(或只是一堆位圖資源或其他東西),我可以用它來編程生成ImageList?

我在圍繞着System.Drawing類開玩笑,沒有任何東西會跳出來。另外,我堅持使用.Net 2.0。

回答

1
Bitmap image1 = ... 
Bitmap image2 = ... 

Bitmap combined = new Bitmap(image1.Width, image1.Height); 
using (Graphics g = Graphics.FromImage(combined)) { 
    g.DrawImage(image1, new Point(0, 0)); 
    g.DrawImage(image2, new Point(0, 0); 
} 

imageList.Add(combined); 
0

只需使用ImageList中的ImageList添加個別圖像即可。所以,像這樣:


Image img = Image.FromStream(/*get stream from resources*/); 
ImageList1.Images.Add(img); 
相關問題