开发者

SplitButton Locked - can't unlock. Why?

I'm working with a split button i开发者_StackOverflown C# on VS2010 for an Outlook Add-In. The code below is very basic testing code that is baffling me. I'm trying to add items to the splitbutton, but I'm told that the collection is read-only. I can't seem to find how to change this, and it's driving me a little batty.

private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
    string s;
    Random r = new Random();

    for (int i = 0; i < 5; i++)
    {
        s = r.Next().ToString();

        RibbonButton rc = this.Factory.CreateRibbonButton();
        rc.Label = s;
        splitButton1.Items.Add(rc);
    }
}


At that point in your code, the Items property is read-only. You can only adjust the items collection:

  • In the Visual Studio Properties Window
  • In the Constructor of the Ribbon Class
  • In the CreateRibbonExtensibilityObject method of the ThisAddin, ThisWorkbook, or ThisDocument class of your project.

Setting Properties That Become Read-Only

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜