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

Add ToolWindow DockLayoutPanel Button

2 Answers 137 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 15 Jan 2013, 05:16 AM
Hi Telerik

I'm using the following code to add button to the tabstrip at the top of some of the tool windows in my RadDock. The button adds no problem and the events for the button work fine. I would like the button to appear at the right hand edge off the tabstrip rather than its position at the moment (which is just after the image I am also adding). See the attached screenshot.

How can I move the button to the Righthand side of the tabstrip?

Many thanks in advance
Regards
Ian Carson

public void SetToolWindowElements()
{
    foreach (ToolWindow tw in rdockMain.DockWindows)
    {
        if (tw != twTemplates && tw != twExecutables && tw != twEquityFunds && tw != twInstrumentLibrary && tw != twScheduleLibrary) continue;
 
        var iconImage = new ImagePrimitive {Image = Resources.alpha_logo24}; //, Padding = new Padding(4, 0, 3, 0)};
        var refreshButton = new RadButtonElement {Image = Resources.Refresh20, ImageAlignment = ContentAlignment.MiddleCenter};
        tw.TabStrip.Height = 28;
 
        if (tw == twInstrumentLibrary)
        {
            refreshButton.Click += InstrumentLibraryRefresh;
        }
        else if (tw == twEquityFunds || tw == twScheduleLibrary)
        {
            refreshButton.Click += ScheduleEquityLibraryRefresh;
        }
 
        if (((ToolTabStrip) tw.TabStrip).CaptionElement.Children[2].Children[0].GetType() != typeof (ImagePrimitive))
        {
            ((ToolTabStrip) tw.TabStrip).CaptionElement.Children[2].Children.Insert(0, iconImage);
        }
 
        if (tw != twEquityFunds && tw != twInstrumentLibrary && tw != twScheduleLibrary) continue;
 
        if (((ToolTabStrip)tw.TabStrip).CaptionElement.Children[2].Children[4].GetType() != typeof(RadButtonElement))
        {
            ((ToolTabStrip)tw.TabStrip).CaptionElement.Children[2].Children.Insert(4, refreshButton);
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 16 Jan 2013, 03:51 AM
Hi Telerik

Answering my own question after a look through the forum a bit harder. I just needed to set the docking type on the button

if (((ToolTabStrip)tw.TabStrip).CaptionElement.Children[2].Children[4].GetType() != typeof(RadButtonElement))
{
    DockLayoutPanel.SetDock(refreshButton, Telerik.WinControls.Layouts.Dock.Right);
    ((ToolTabStrip)tw.TabStrip).CaptionElement.Children[2].Children.Insert(4, refreshButton);
}
0
Julian Benkov
Telerik team
answered on 16 Jan 2013, 01:27 PM
Hi Ian,

I am glad to hear that you have solved your issue. 
Do not hesitate to contact us if you have further questions or issues.

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