Is it possible to add a button next to the close buton?

9 posts, 1 answers
  1. Per
    Per avatar
    116 posts
    Member since:
    Jan 2008

    Posted 04 Aug 2009 Link to this post

    Hi!

    Is its possible to add a button next to the close button in the far right corner of a dock control in mdi tab mode ?

    I want to have a "create new tab" button next to the close button :)

    Regards,
    Per
  2. Answer
    Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 06 Aug 2009 Link to this post

    Hello Per,

    Thank you for contacting us. The major benefit of TPF (Telerik Presentation Framework) is its tree of elements, which is freely modifiable by the user. So, you may get a direct access to that tree and insert a RadButtonElement:

    private void AddButtonToDockTabStrip(DockTabStrip strip)  
    {  
        RootRadElement root = strip.RootElement;  
        DockLayoutPanel buttonHolder;  
        int insertIndex;  
        if (strip.DockType == DockType.Document)  
        {  
            buttonHolder = root.Children[0].Children[0] as DockLayoutPanel;  
            insertIndex = 0;  
        }  
        else 
        {  
            buttonHolder = root.Children[0].Children[0].Children[2] as DockLayoutPanel;  
            insertIndex = buttonHolder.Children.Count - 1;  
        }  
     
        RadButtonElement el = new RadButtonElement();  
        el.Text = "MyButton";  
        DockLayoutPanel.SetDock(el, Telerik.WinControls.Layouts.Dock.Right);  
        buttonHolder.Children.Insert(insertIndex, el);  

    Please, find attached a screenshot of what this code produces.

    I hope this help. Please, do not hesitate to write back if you need further assistance.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Per
    Per avatar
    116 posts
    Member since:
    Jan 2008

    Posted 06 Aug 2009 Link to this post

    Perfect, this is just what I was looking for!

    Your function takes a DockTabStrip as argument.
    I'm using MDI with AutoDetectMDIChildren enabled so my RadDock is completely empty at design time.

    How can I find my DockTabStrip in runtime?

    (I only have one dock window)

    Regards
    Per
  5. Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 07 Aug 2009 Link to this post

    Hi Per,

    Each DockWindow has a property DockTabStrip which gives you the current strip in which the window resides. Please, note that this property may return null if the window is not yet parented. Do not hesitate to write back if you have any other questions.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Per
    Per avatar
    116 posts
    Member since:
    Jan 2008

    Posted 07 Aug 2009 Link to this post

    Hi and thanks for your reply :)

    I got it working using the following code
    ----------------------

     

    AddButtonToDockTabStrip

     

    (CType

     

    (DocumentContainer1.Controls(0), Telerik.WinControls.UI.Docking.DockTabStrip))

     

    ----------------------

    There is probobly a better way but I just couldnt figure out how.
    Anyway, it's working perfect now.

    Thanks for your help!

    Regards
    Per
  7. Andrew Stanford
    Andrew Stanford avatar
    7 posts
    Member since:
    Jul 2009

    Posted 16 Aug 2009 Link to this post

    Hi,

    Just what I was looking for, but I wonder if it is possible to perform this task in the designer?
  8. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 18 Aug 2009 Link to this post

    Hi Andrew Stanford,

    Currently this is not a supported feature at design-time and the given solution is only valid for run-time.

    Sincerely yours,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Andrew Stanford
    Andrew Stanford avatar
    7 posts
    Member since:
    Jul 2009

    Posted 18 Aug 2009 Link to this post

    Thanks for the reply. I added the new buttons in code, but now the "docking" features seem to have been lost. i.e. if I click and drag the tool window I normally get the dock positioning indicators dosplayed and I can dock the window in a new location or make it "float".

    With the buttons added at runtime I no longer have this function?
  10. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 19 Aug 2009 Link to this post

    Hi Andrew Stanford,

    Please view the answer to your question in your last support ticket.

    Regards,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for WinForms is Visual Studio 2017 Ready