1
因此,我正在製作一個Web瀏覽器。這是一個標籤式網頁瀏覽器,我希望能夠在相關標籤上顯示網頁圖標。我試圖使用的代碼說:「不可使用的成員'TabControl.TabPages'不能像使用方法一樣使用」C# - 有關TabControl圖像索引的問題
我知道我不能使用它作爲方法,但它是唯一的方法可以看到添加網頁圖標。無論如何要解決它,而仍然能夠保持我的代碼?這裏是我正在使用的代碼:
private void web_documentcompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser sender_wb = (WebBrowser)sender;
int index_wb = Convert.ToInt32(sender_wb.Name.Replace("wb", ""));
try
{
//Try to get website favicon using Google S2 Service.
WebClient wc = new WebClient();
System.IO.MemoryStream ms = new System.IO.MemoryStream(wc.DownloadData("http://www.google.com/s2/favicons?domain=" + sender_wb.Url.Host));
Image img = Image.FromStream(ms);
FaviconCollection.Images.Add(img);
tabControl1.TabPages(index_wb).ImageIndex = FaviconCollection.Images.Count - 1;
ms.Close();
}
catch (Exception ex)
{
//If failed, show WWW icon.
tabControl1.TabPages(index_wb).ImageIndex = 0;
}
}
TabPages是集合,使用方括號 –
如果我不能使用現有的代碼,我真的不在乎:) – Bradley