想做个插件式开发,界面用Dotnetbar的RibbonControl,需要通过代码动态的向RibbonControl控件添加项
示例代码如下:
RibbonTabItem rti = new RibbonTabItem(); rti.Text = "tabitem"; RibbonPanel rp = new RibbonPanel(); rp.Text = "panel"; rti.Panel = rp; rp.Dock = DockStyle.Fill; this.ribbonControl1.Controls.Add(rp); this.ribbonControl1.Items.Add(rti); RibbonBar rb = new RibbonBar(); ButtonItem bi = new ButtonItem("bi"); bi.Text = "www"; rb.Items.Add(bi); rp.Controls.Add(rb);
涉及到的类有RibbonTabItem,RibbonPanel,RibbonBar,ButtonItem(根据需要可以替换为其他的类型);
个人理解RibbonTabItem代表的是RibbonControl上的Tab标签,RibbonPanel代表的是标签下面的空白区,可以拖放控件