本文整理汇总了C#中Microsoft.Office.Core.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Core.GetType方法的具体用法?C# Microsoft.Office.Core.GetType怎么用?C# Microsoft.Office.Core.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Core
的用法示例。
在下文中一共展示了Microsoft.Office.Core.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveClickEvent
private void RemoveClickEvent(Office.CommandBarButton b)
{
//System.Reflection.FieldInfo f = typeof(Office.CommandBarButton).GetField("EventClick", BindingFlags.Static | BindingFlags.NonPublic);
System.Reflection.FieldInfo f = typeof(Office.CommandBarButton).GetField("Click", BindingFlags.Static | BindingFlags.NonPublic);
if (f == null) return;
object o = f.GetValue(b);
System.Reflection.PropertyInfo p = b.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance);
EventHandlerList l = (EventHandlerList)p.GetValue(b, null);
l.RemoveHandler(o, l[o]);
/*FieldInfo f1 = typeof(Control).GetField("EventClick",
BindingFlags.Static | BindingFlags.NonPublic);
object obj = f1.GetValue(b);
PropertyInfo pi = b.GetType().GetProperty("Events",
BindingFlags.NonPublic | BindingFlags.Instance);
EventHandlerList list = (EventHandlerList)pi.GetValue(b, null);
list.RemoveHandler(obj, list[obj]);*/
}
示例2: AddCommandBar
/// <summary>
/// Add a new command bar to PPT.
/// </summary>
/// <param name="bars">the bars object to which to add the new bar</param>
/// <param name="name">the name of the bar.</param>
/// <param name="position">the position of the bar.</param>
/// <param name="visible">should the bar be visible immediately</param>
/// <param name="replace">should existing bars of the same name be deleted (an error is thrown if replace is false and a bar of the same name exists)</param>
/// <returns>the newly created bar</returns>
public Core.CommandBar AddCommandBar(Core.CommandBars bars, string name,
Core.MsoBarPosition position, bool visible, bool replace)
{
Debug.Assert(bars != null, "bars must be non-null");
Debug.Assert(name != null && name != "", "name must be non-null and non-empty");
Debug.Assert(Enum.IsDefined(position.GetType(), position), "position has an invalid value");
Core.CommandBar newBar = null;
// Delete all bars with the same name.
foreach (Core.CommandBar bar in bars)
if (bar.Name == name)
{
if (replace)
{
newBar = bar;
break;
}
else
throw new Exception("A bar by the name \"" + name + "\" already exists.");
}
if (newBar == null)
newBar = bars.Add(name, position, false, false);
if (newBar.Visible != visible)
newBar.Visible = visible;
this.myObjectCache.Add(newBar);
return newBar;
}