1 for (int j = 1; j < 10; j++) 2 { 3 ButtonItem btnItem = new ButtonItem(); 4 btnItem.Name = "wuyfBtn" + j.ToString(); 5 btnItem.Text = "新按钮哦!" + j.ToString(); 6 btnItem.Visible = true; 7 btnItem.Command = cmd_Hello; 8 btnItem.CommandParameter = new string[] { j.ToString() + "__" + "111", j.ToString() + "__" + "222", j.ToString() + "__" + "333" }; 9 10 11 for (int k = 0; k < 3; k++) 12 { 13 ButtonItem subItem = new ButtonItem(); 14 subItem.Name = btnItem.Name + "_sub_" + j.ToString(); 15 subItem.Text = j.ToString() + "->" + "sub_" + k.ToString(); 16 subItem.Visible = true; 17 subItem.Command = cmd_Hello; 18 subItem.CommandParameter = new string[] {k.ToString() + "__sub_" + "111", k.ToString() + "__" + "222", k.ToString() + "__" + "333" }; 19 btnItem.SubItems.Add(subItem); 20 21 } 22 btnItem.ShowSubItems = true; 23 24 ribbonControl1.QuickToolbarItems.Add(btnItem); 25 RibbonTabItem ribTab = ribbonControl1.CreateRibbonTab("新建的Tab哦" + j.ToString(), "newTab" + j.ToString()); 26 27 ribTab.Visible = true; 28 }