Add ToolWindow DockLayoutPanel Button

3 posts, 0 answers
  1. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 14 Jan 2013 Link to this post

    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. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 15 Jan 2013 Link to this post

    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);
    }
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 16 Jan 2013 Link to this post

    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.
Back to Top