インターネット上のテキスト/エラーの一部を簡単に検索するために、Visual Studio Add-in を使用して Web Search Add-in を実行しています。私はまだ以下のようにすることができます。
そして、リンクの前に写真を置きたいです。たとえば、「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);
}
これは私のエラー コードです: タイプ 'string' を 'stdole.StdPicture' に暗黙的に変換できません。タイプ string を stdole.StdPicture に変換しませんでした。私は何をしますか?「oControl.Picture = item.imageUrl;」です。ライン間違い?または、imageUrlの文字列型を行う必要がありますか? または、他の何か?