6 Answers, 1 is accepted
0
Richard Slade
Top achievements
Rank 2
answered on 11 Oct 2010, 05:17 PM
Hi,
As far as I know it's not possible to add a close button in the place you want it.
You could though add a close button (as a RadButtonElement) to the group in the RibbonTab and then close the tab programatically on the click of that button
http://www.telerik.com/help/winforms/ribbonbarprogrammingtabsandchunks.html
Hope that helps
Richard
As far as I know it's not possible to add a close button in the place you want it.
You could though add a close button (as a RadButtonElement) to the group in the RibbonTab and then close the tab programatically on the click of that button
http://www.telerik.com/help/winforms/ribbonbarprogrammingtabsandchunks.html
Hope that helps
Richard
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 11 Oct 2010, 10:34 PM
Hello Dror,
You can inherit the RibbonTab base class and add some custom elements to the children collection,
I have prepared a very small example, it should get you started:
Please see the attached image if this is what you wanted.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
You can inherit the RibbonTab base class and add some custom elements to the children collection,
I have prepared a very small example, it should get you started:
using System; using System.Drawing; using System.Windows.Forms; using Telerik.WinControls; using Telerik.WinControls.UI; public partial class RadRibbonForm1 : Telerik.WinControls.UI.RadRibbonForm { public RadRibbonForm1() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); var tabItem1 = new CustomRibbonTab("Manage"); var tabItem2 = new CustomRibbonTab("Remove"); radRibbonBar1.CommandTabs.AddRange(new CustomRibbonTab[] { tabItem1, tabItem2 }); } } public class CustomRibbonTab : RibbonTab { private RadButtonElement radButtonElement; protected override Type ThemeEffectiveType { get { return typeof(TabItem); } } private Timer focusTimer; public CustomRibbonTab() : base() { CreateTimer(); } public CustomRibbonTab(string text) : base(text) { CreateTimer(); } private void CreateTimer() { this.focusTimer = new Timer { Interval = 500 }; this.focusTimer.Tick += delegate { this.radButtonElement.Visibility = ElementVisibility.Collapsed; }; } protected override void CreateChildElements() { base.CreateChildElements(); radButtonElement = new RadButtonElement("x"); radButtonElement.Size = new Size(10, 10); radButtonElement.MinSize = new Size(10, 10); radButtonElement.MaxSize = new Size(10, 10); radButtonElement.Click += new EventHandler(radButtonElement_Click); radButtonElement.MouseEnter += new EventHandler(radButtonElement_MouseEnter); radButtonElement.MouseLeave += new EventHandler(radButtonElement_MouseLeave); radButtonElement.BorderElement.Visibility = ElementVisibility.Collapsed; radButtonElement.Visibility = ElementVisibility.Collapsed; this.Children.Add(radButtonElement); } void radButtonElement_MouseLeave(object sender, EventArgs e) { this.OnMouseLeave(e); } void radButtonElement_MouseEnter(object sender, EventArgs e) { this.OnMouseEnter(e); } void radButtonElement_Click(object sender, EventArgs e) { ((Telerik.WinControls.UI.RadTabStripElement)(this.ParentTabStrip)).Items.Remove(this); } protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); focusTimer.Stop(); radButtonElement.Visibility = ElementVisibility.Visible; } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); focusTimer.Start(); } protected override SizeF ArrangeOverride(SizeF finalSize) { finalSize = new SizeF(finalSize.Width + this.Children[3].DesiredSize.Width, finalSize.Height); base.ArrangeOverride(finalSize); this.Children[3].Arrange(new RectangleF((int)(finalSize.Width - 1.7 * this.Children[3].Size.Width), (finalSize.Height / 2) - (this.Children[3].DesiredSize.Height / 2 + 1), finalSize.Width, this.Children[3].DesiredSize.Height)); return finalSize; } protected override void DisposeManagedResources() { radButtonElement.Click -= new EventHandler(radButtonElement_Click); radButtonElement.MouseEnter -= new EventHandler(radButtonElement_MouseEnter); radButtonElement.MouseLeave -= new EventHandler(radButtonElement_MouseLeave); base.DisposeManagedResources(); } }Please see the attached image if this is what you wanted.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
Emanuel Varga
Top achievements
Rank 1
answered on 11 Oct 2010, 10:35 PM
0
Richard Slade
Top achievements
Rank 2
answered on 11 Oct 2010, 11:11 PM
Works well Emanuel. nice.
0
Sason
Top achievements
Rank 1
answered on 12 Oct 2010, 01:22 PM
Great !!!
thank you.
thank you.
0
Emanuel Varga
Top achievements
Rank 1
answered on 12 Oct 2010, 01:33 PM
Hello Dror, you're very welcome, it was fun.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga