我有以下代碼從Url讀取圖像並將圖像添加到ImageList。當添加到ImageList中Image.Tag爲空時在C#中
WebClient oWebClient = new WebClient();
Uri oUri = new Uri("http://www.mysite.com/images/image1.jpg");
try
{
Image oImage = Image.FromStream(oWebClient.OpenRead(oUri));
oImage.Tag = "hello World";
imageList1.Images.Add("test", oImage);
}
catch(Exception ex)
{
listBox1.Items.Add("Error getting photo: " + ex.Message);
}
一切工作正常,除了由於某種原因,當我檢查ImageList1對象中的圖像標籤是空的嗎?這是爲什麼發生?
你確定你正在檢查'Image.Tag'而不是'ImageList.Tag'嗎? –
是的,我正在查看Image.Tag,我ImageList中的唯一圖像。 – Tommassiov