我有一个 Excel 加载项,它有 2 个按钮,我希望在加载加载项时隐藏第二个按钮。这是我的代码:
public void OnStartupComplete(ref System.Array custom)
{
object omissing = System.Reflection.Missing.Value;
CommandBarButton Button1 = (CommandBarButton)g_PLCToolBarInstance.Controls.Add(1, omissing, omissing, omissing, omissing);
Button1 .Visible = true;
Button1 .Enabled = true;
Button1 .Caption = "Button1";
Button1 .Style = MsoButtonStyle.msoButtonIcon;
Button1 .Picture = PictureDispConverter.ToIPictureDisp(OneIco);
CommandBarButton Button2 = (CommandBarButton)g_PLCToolBarInstance.Controls.Add(1, omissing, omissing, omissing, omissing);
Button2 .Visible = false;
Button2 .Enabled = false;
Button2 .Caption = "Button2";
Button2 .Style = MsoButtonStyle.msoButtonIcon;
Button2 .Picture = PictureDispConverter.ToIPictureDisp(TwoIco);
....
}
问题是第二个按钮被绘制,然后被移除(而不是从一开始就被隐藏),在工具栏选项下拉菜单上留下了 TwoIco 的幽灵图像......
代替 ...
请问有什么想法吗?!