English 中文(简体)
强烈地将RibbonButtons列入Adin山谷集
原标题:Dynamically adding RibbonButtons in Word Addin throws Collection is readonly

我对Add.Ins说得很新,并试图加入Ribbon小组。 每一组都积极增加RibbonMenu,然后在小组内增加RibbonButtons。

我看着出色的工作,看来是ok,但每次收看都看着。

例如:1.Items.add(新RibbonButton(RibbonButton));它向我说,收监工作是阅读的。

但是,如果把藏书贴上标识,是否将重新登上旗帜,这清楚表明藏书并非只读吗?

失踪了。

最佳回答

一旦里博博斯装满,收藏品就只能读到。

为了动态地改变Ribbon的控制,你需要在Ribbon建筑商中这样做。

见http://msdn.microsoft.com/en-us/library/bb608623.aspx#SettingReadOnlyProperties>http://msdn.microsoft.com/en-us/library/bb608623.aspx#SettingReadOnlyProperties。

问题回答

Are you trying to add buttons to RibbonMenu or RibbonGroup? In your description you ve said you want to add buttons to the menu, but the example you cited is trying to add a button to a ribbon group [I m assuming group1 is a group not a menu!].

You should be able to add buttons to RibbonMenu, but if it s RibbonGroup you want then you re out of luck.
Here s the code comment for the Items property in RibbonGroup:

// Summary:
//     Gets the controls in the group.
//
// Returns:
//     The collection of controls in the group.
//
// Exceptions:
//   System.InvalidOperationException:
//     You try to add, remove, or replace a Microsoft.Office.Tools.Ribbon.RibbonControl
//     after the Ribbon is loaded.
IList<RibbonControl> Items { get; }

That s the reason you re getting an error, and that s also why the IsReadOnly property of the collection is set to false.
The Designer needs to be able to modify the items in RibbonGroup when it s creating the ribbon, but once it s loaded you can t make any modifications to it.

<>说明: 如果你想在传单上添加斜线,将Dynamic改为在您的RibbonMenu项目财产窗口上填写(或你可以在设计师的代码中填入),否则你就会再次陷入同一个例外。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签