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); }
protected internal override void SetDataBoundItem(bool dataBinding, object value) { base.SetDataBoundItem(dataBinding, value); CommandBarStripElement commandBarStripElement = value as CommandBarStripElement; if (value == null) { return; } this.Name = commandBarStripElement.DisplayName; this.Visible = commandBarStripElement.VisibleInCommandBar; commandBarStripElement.RadPropertyChanged += new RadPropertyChangedEventHandler(this.stripElement_RadPropertyChanged); }
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; }
private void stripElement_RadPropertyChanged(object sender, RadPropertyChangedEventArgs e) { if (e.Property == CommandBarStripElement.VisibleInCommandBarProperty) { CommandBarStripElement dataBoundItem = this.DataBoundItem as CommandBarStripElement; if (dataBoundItem != null) { this.Visible = dataBoundItem.VisibleInCommandBar; } } if (e.Property != RadElement.NameProperty) { return; } CommandBarStripElement dataBoundItem1 = this.DataBoundItem as CommandBarStripElement; if (dataBoundItem1 == null) { return; } this.Name = dataBoundItem1.DisplayName; }
/// <summary> /// /// </summary> /// <param name="strip"></param> /// <param name="overflowVisible"></param> /// <param name="gripVisible"></param> public static void UpdateVisibility(this CommandBarStripElement strip, bool overflowVisible, bool gripVisible) { strip.OverflowButton.Visibility = overflowVisible ? ElementVisibility.Visible : ElementVisibility.Hidden; strip.Grip.Visibility = gripVisible ? ElementVisibility.Visible : ElementVisibility.Hidden; }
/// <summary> /// /// </summary> /// <param name="strip"></param> public static void SetPropertiesToToolStrip(this CommandBarStripElement strip) { strip.StretchHorizontally = true; strip.UpdateVisibility(false, false); }