0

我正在使用 Visual Studio Add-in 执行 Web Search Add-in,以便在 Internet 上轻松搜索一些文本/错误。我可以做如下。

图一

我想把图片放在链接前面。比如我想把“Stack Overflow”图片放在“Stack Overflow”链接前面。所以我编码如下,但我无法放一张图片。一切正常。

        CommandBarPopup oPopup = (CommandBarPopup)
            oCommandBar.Controls.Add(MsoControlType.msoControlPopup,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value, 1, true);
        oPopup.Caption = "Web Search";

        oPopup.BeginGroup = true;

        var webSearchURLs = new[]
        {
            new {name="Google", imageUrl="../images/azizyilmaznet.ico", Url="http://www.google.com/search?q=" , Seq=1},
            new {name="MSDN", imageUrl="../images/azizyilmaznet.ico", Url="http://social.msdn.microsoft.com/search/en-US?query=" , Seq=2},
            new {name="Code Project", imageUrl="../images/azizyilmaznet.ico", Url="http://www.codeproject.com/search.aspx?q=" , Seq=3},
            new {name="Stack Overflow", imageUrl="../images/azizyilmaznet.ico", Url="http://stackoverflow.com/search?q=" , Seq=4},
            new {name="Yahoo", imageUrl="../images/azizyilmaznet.ico", Url="http://search.yahoo.com/bin/search?p=" , Seq=5},
            new {name="Bing", imageUrl="../images/azizyilmaznet.ico", Url="http://www.bing.com/search?q=" , Seq=6},
            new {name="Ask", imageUrl="../images/azizyilmaznet.ico", Url="http://www.ask.com/web?q=" , Seq=7}
        };

        CommandBarButton oControl;
        foreach (var item in webSearchURLs)
        {
            oControl =
            (CommandBarButton)oPopup.Controls.Add(MsoControlType.msoControlButton,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value, item.Seq, true);
            oControl.Caption = item.name;

            // Error on below line
            oControl.Picture = item.imageUrl;

            oControl.Tag = item.Url;
            oControl.TooltipText = "Search " + item.name + " for...";
            oControl.Click += new _CommandBarButtonEvents_ClickEventHandler(oControl_Click);
        }

这是我的错误代码:无法将类型“字符串”隐式转换为“stdole.StdPicture”。我没有将类型字符串转换为 stdole.StdPicture。我该怎么办?是'oControl.Picture = item.imageUrl;' 线路错了?或者我应该为 imageUrl 做字符串类型吗?或者是其他东西?

4

0 回答 0