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

Drop down control on Document Window Tab

7 Answers 178 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Tejas
Top achievements
Rank 1
Tejas asked on 13 Mar 2012, 01:29 AM
Hello,
I was wondering if there is a way to add a drop-down menu on the tab of a document window in the dock. It would be exactly same as the little down pointing arrow next to the close button on the right-hand side which lists the active documents. Just that I would want it on each tab next to that tab's close button.

Thanks!

7 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 15 Mar 2012, 03:06 PM
Hello Tejas,

Thank you for your question.

Currently, such behavior cannot be achieved due to the internal implementation of RadDock. However, such functionality seems reasonable and therefore I have logged this as a feature request in our Public Issue Tracking System. Here you can find the PITS entry. You can subscribe to it and track it for changes. You can also vote for it to increase its priority.

Your Telerik points have been updated for the feature request.

Should you have any further questions, do not hesitate to ask.

Regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Tejas
Top achievements
Rank 1
answered on 15 Mar 2012, 08:33 PM
Thank you for the response.

A follow up question: Can we add/remove items in the context menu for the docwindow tabstrip? While not the ideal solution, it would suffice for now.

Otherwise, would the dropdown menu functionality work using through some other Radcontrol such as RadPageView? Basically, we have tab specific options that need to be accessed.

Any suggestions would be welcome.
0
Ivan Todorov
Telerik team
answered on 19 Mar 2012, 10:26 AM
Hello Tejas,

Yes, you can customize the context menus of RadDock. The following code snippet demonstrates how:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.radDock1.GetService<ContextMenuService>().ContextMenuDisplaying += new ContextMenuDisplayingEventHandler(Form32_ContextMenuDisplaying);
    }
 
    void Form32_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e)
    {
        if (e.MenuType == ContextMenuType.ActiveWindowList)
        {
            e.MenuItems.Add(new RadMenuItem("Custom overflow item"));
        }
        else if(e.MenuType == ContextMenuType.DockWindow)
        {
            if (e.DockWindow is DocumentWindow)
            {
                e.MenuItems.Add(new RadMenuItem("Action specific to " + e.DockWindow.TabStripItem.Text));
            }
        }
    }
}

More information about the ContextMenuService can be found in this help article.

As to inserting a dropdown button inside RadPageView tabs, this is also possible to achieve. The following code snippet demonstrates this:
public Form1()
{
    InitializeComponent();
    this.radPageView1.ItemCreating += new EventHandler<RadPageViewItemCreatingEventArgs>(radPageView1_ItemCreating);
    this.radPageView1.Pages.Add(new RadPageViewPage() { Text = "Page 1" });
    this.radPageView1.Pages.Add(new RadPageViewPage() { Text = "Page 2" });
    this.radPageView1.Pages.Add(new RadPageViewPage() { Text = "Page 3" });
}
 
void radPageView1_ItemCreating(object sender, RadPageViewItemCreatingEventArgs e)
{
    e.Item = new MyPageViewItem();
}
 
public class MyPageViewItem : RadPageViewStripItem
{
    CommandBarDropDownButton button;
 
    protected override void CreateChildElements()
    {
        base.CreateChildElements();
        this.button = new CommandBarDropDownButton();
        this.button.Items.Add(new RadMenuItem("item1"));
        this.button.Items.Add(new RadMenuItem("item2"));
        this.button.Items.Add(new RadMenuItem("item3"));
        this.button.MinSize = new Size(16,16);
        this.button.Image = null;
        this.Children.Add(button);
    }
 
    protected override SizeF MeasureOverride(SizeF availableSize)
    {
        SizeF size = base.MeasureOverride(availableSize);
        size.Width += button.DesiredSize.Width;
        size.Height = Math.Max(size.Height, button.DesiredSize.Height);
        return size;
    }
 
    protected override void ArrangeChildren(SizeF available)
    {
        base.ArrangeChildren(available);
        button.Arrange(new RectangleF(available.Width - button.DesiredSize.Width, 0, button.DesiredSize.Width, available.Height));
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadPageViewStripItem);
        }
    }
}

I hope you find this information useful. Feel free to write back if you need further assistance.

All the best,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
John
Top achievements
Rank 1
answered on 18 Feb 2013, 03:37 PM
Hi -
I am able to add a context menu item in the ContextMenuDisplaying event as you have specified in this post, however, the ContextMenuService ContextMenuItemClicked event does not fire when I click the newly added item. 

I am using v.2012.1.321.40 of RadControls for Winforms.

Any help would be appreciated.

Thanks!
John
0
Stefan
Telerik team
answered on 21 Feb 2013, 09:22 AM
Hi John,

Since those are not default items, you have to subscribe to the custom menu items Click events:
void Form32_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e)
{
    if (e.MenuType == ContextMenuType.ActiveWindowList)
    {
        RadMenuItem customOverflowItem = new RadMenuItem("Custom overflow item");
        customOverflowItem.Click += customOverflowItem_Click;
        e.MenuItems.Add(customOverflowItem);
    }
    else if (e.MenuType == ContextMenuType.DockWindow)
    {
        if (e.DockWindow is DocumentWindow)
        {
            RadMenuItem actionSpecificTo = new RadMenuItem("Action specific to " + e.DockWindow.TabStripItem.Text);
            actionSpecificTo.Click +=actionSpecificTo_Click;
            e.MenuItems.Add(actionSpecificTo);
        }
    }
}
 
void actionSpecificTo_Click(object sender, EventArgs e)
{
    //do smth
}
 
void customOverflowItem_Click(object sender, EventArgs e)
{
    //do smth
}

I hope this helps.
 
Kind regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
John
Top achievements
Rank 1
answered on 21 Feb 2013, 01:57 PM
OK, great, thanks for the reply.

That works as you described, however, I was hoping to be able to use the ContextMenuClickEventArgs to use the e.DockWindow property, which I will accomplish by setting a class level variable in the ContextMenuDisplaying handler.

Are there plans to add menu customization to the ContextMenuService in  the future?

0
Stefan
Telerik team
answered on 26 Feb 2013, 09:37 AM
Hi Tejas,

Thank you for writing back.

Currently, the ContextMenuItemClicked event is fired for the default items only and you have to handle the custom ones. I would suggest that you save the desired window in the Tag of the menu item and use it in the Click event handler:
actionSpecificTo.Tag = e.DockWindow;
 
///
void actionSpecificTo_Click(object sender, EventArgs e)
{
    RadMenuItem item = (RadMenuItem)sender;
    DockWindow dockWin = (DockWindow)item.Tag;
    //here you have the DockWindow
}

Let us know if you need anything else.

Greetings,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
Dock
Asked by
Tejas
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Tejas
Top achievements
Rank 1
John
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or