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

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

8 Answers 126 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Per
Top achievements
Rank 1
Per asked on 04 Aug 2009, 06:27 PM
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

8 Answers, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 06 Aug 2009, 07:18 AM
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.
0
Per
Top achievements
Rank 1
answered on 06 Aug 2009, 09:44 AM
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
0
Georgi
Telerik team
answered on 07 Aug 2009, 07:38 AM
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.
0
Per
Top achievements
Rank 1
answered on 07 Aug 2009, 07:41 AM
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
0
Andrew Stanford
Top achievements
Rank 1
answered on 16 Aug 2009, 11:00 AM
Hi,

Just what I was looking for, but I wonder if it is possible to perform this task in the designer?
0
Julian Benkov
Telerik team
answered on 18 Aug 2009, 10:57 AM
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.
0
Andrew Stanford
Top achievements
Rank 1
answered on 18 Aug 2009, 11:23 AM
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?
0
Julian Benkov
Telerik team
answered on 19 Aug 2009, 08:29 AM
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.
Tags
Dock
Asked by
Per
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Per
Top achievements
Rank 1
Andrew Stanford
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or