This is a migrated thread and some comments may be shown as answers.

Add new button on Title bar of RadRibbonForm

1 Answer 125 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
nguyen
Top achievements
Rank 1
nguyen asked on 17 Oct 2014, 04:41 PM
Hello,

Is there any way to add a button on title bar of RadRibbonForm or a textbox like the image below?

Thanks & Regards,

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Oct 2014, 08:11 AM
Hello Nguyen,

Thank you for writing.

You can achieve your requirement by inserting the desired search box in the RibbonBarElement.RibbonCaption.SystemButtons.Children collection. Here is a sample implementation:
public Form1()
{
    InitializeComponent();
 
    this.AllowAero = false;
 
    RadTextBoxElement tb = new RadTextBoxElement();
    tb.MinSize = new System.Drawing.Size(200, 0);
 
    RadButtonElement button = new RadButtonElement();
    button.ButtonFillElement.BackColor = Color.Transparent;
    button.ButtonFillElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    button.ShowBorder = false;
    button.Click+=button_Click;
    button.Image = Properties.Resources.zoom;
    button.Padding = new Padding(2, 0, 2, -2);
    button.Margin = new Padding(0, 0, 0, 0);
     
    StackLayoutElement stackPanel = new StackLayoutElement();
    stackPanel.Orientation = Orientation.Horizontal;
    stackPanel.Margin = new Padding(1, 0, 1, 0);
    stackPanel.Children.Add(button);
 
    RadTextBoxItem tbItem = tb.TextBoxItem;
    tbItem.NullText = "Quick Launch (Ctrl+Q)";
    tb.Children.Remove(tbItem);
 
    DockLayoutPanel dockPanel = new DockLayoutPanel();
    dockPanel.Children.Add(stackPanel);
    dockPanel.Children.Add(tbItem);
    DockLayoutPanel.SetDock(tbItem, Telerik.WinControls.Layouts.Dock.Left);
    DockLayoutPanel.SetDock(stackPanel, Telerik.WinControls.Layouts.Dock.Right);
    tb.Children.Add(dockPanel);
 
    this.radRibbonBar1.RibbonBarElement.RibbonCaption.SystemButtons.Children.Insert(0, tb);
}
 
private void button_Click(object sender, EventArgs e)
{
    RadMessageBox.Show("Search");
}

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
RibbonBar
Asked by
nguyen
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or