void AddToolStrip() { RadCommandBar commandBar = new RadCommandBar(); commandBar.ImageList = this.imageList1; CommandBarRowElement element = new CommandBarRowElement(); element.AllowDrag = false; commandBar.Rows.Add(element); CommandBarStripElement toolStripItem = new CommandBarStripElement(); toolStripItem.AllowDrag = false; toolStripItem.OverflowButton.Visibility = ElementVisibility.Collapsed; toolStripItem.StretchHorizontally = true; element.Strips.Add(toolStripItem); CommandBarButton button1 = new CommandBarButton(); button1.ImageIndex = 0; toolStripItem.Items.Add(button1); CommandBarButton button2 = new CommandBarButton(); button2.ImageIndex = 1; toolStripItem.Items.Add(button2); CommandBarButton button3 = new CommandBarButton(); button3.ImageIndex = 2; toolStripItem.Items.Add(button3); CommandBarButton button4 = new CommandBarButton(); button4.ImageIndex = 3; toolStripItem.Items.Add(button4); CommandBarButton button5 = new CommandBarButton(); button5.ImageIndex = 4; toolStripItem.Items.Add(button5); commandBar.EndInit(); RadMenuContentItem item = new RadMenuContentItem(); item.ContentElement = new RadHostItem(commandBar); item.MinSize = new Size(120, 31); this.radMenuItem1.Items.Add(item); }
public Form1() { InitializeComponent(); CommandBarRowElement row = new CommandBarRowElement(); CommandBarStripElement strip = new CommandBarStripElement(); row.Strips.Add(strip); radCommandBar1.Rows.Add(row); foreach (RadPageViewPage page in radPageView1.Pages) { if (strip.Items.Count > 3) { row = new CommandBarRowElement(); strip = new CommandBarStripElement(); row.Strips.Add(strip); radCommandBar1.Rows.Add(row); } CommandBarButton pageButton = new CommandBarButton(); pageButton.DrawText = true; pageButton.Orientation = Orientation.Horizontal; pageButton.Image = null; pageButton.Text = page.Item.Text; pageButton.Click += new EventHandler(pageButton_Click); pageButton.StretchHorizontally = true; strip.Items.Add(pageButton); strip.StretchHorizontally = true; strip.OverflowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; //adding a label to each page in order to verify the change when a command bar button is clicked RadLabel pageTitle = new RadLabel(); pageTitle.Text = "Current page = " + page.Item.Text; pageTitle.Location = new Point(10, 10); page.Controls.Add(pageTitle); } RadPageViewStripElement stripElement = radPageView1.ViewElement as RadPageViewStripElement; stripElement.ItemContainer.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; }