Customize the title bar of a DockPanel

4 posts, 0 answers
  1. kdev
    kdev avatar
    16 posts
    Member since:
    Apr 2007

    Posted 14 Aug 2007 Link to this post

    Hi,

    I create a custom DockPanel and I want to override the menu shown when we click the DropDownButton.
    is that possible?
    if not, can we add a second DropDownButton to the title bar of the DockPanel ?
    Or is there a way to customize this title bar ? 

    Thanks,
    Kort
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 15 Aug 2007 Link to this post

    Hi kort,

    You can change the dropdown menu as follows:
     
    private void ChangeDropDownMenu(DockPanel dockPanel)  
            {  
                if (dockPanel.DefaultPresenter != null && dockPanel.DefaultPresenter is DockPresenterControl)  
                {  
                    RadItem dockPresenterElement = ((DockPresenterControl)dockPanel.DefaultPresenter).DockPresenterElement;  
                    ClassSelector selector = new ClassSelector("DockPresenterCaptionDropDown");  
                    RadDropDownButtonElement dropDownButton = selector.GetSelectedElements(dockPresenterElement)[0] as RadDropDownButtonElement;  
                    this.AddMenuItems(dropDownButton);  
                }  
            }  
     
            private void AddMenuItems(RadDropDownButtonElement dropDownButton)  
            {  
                dropDownButton.Items.Clear();  
     
                RadMenuItem menuItem = new RadMenuItem();  
                menuItem.Text = "Some Text";  
                dropDownButton.Items.Add(menuItem);  
     
                menuItem.Click += new EventHandler(menuItem_Click);  
            }  
     
            void menuItem_Click(object sender, EventArgs e)  
            {  
                MessageBox.Show("Menu item was clicked.");  
            } 

    It is important that you call the ChangeDropDownMenu method after a call to SetDock:
     
    this.dockingManager1.SetDock(dockPanel, dockPosition);  
     
    this.ChangeDropDownMenu(dockPanel); 

    Hope that helps.

     
    Sincerely yours,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. kdev
    kdev avatar
    16 posts
    Member since:
    Apr 2007

    Posted 28 Aug 2007 Link to this post

    Hi Jordan,

    it works fine, thanks

    But when I change the DockPanel dock state (Drag&Drop it), I got the original menu. perhaps that we call the SetDock method. So I try to call ChangeDropDownMenu in the Dockpanel.Activated event but it works only if we select an other panel before. I try also with the Dockingmanager.DockingStateChanged event without success :(

    In which Docking event, have I to call the ChangeDropDownMenu?

    Regards  
    Kort
  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 29 Aug 2007 Link to this post

    Hi Kort, 

    You can use this code snippet:

    (dockingManager1.PrimarySite as DockSite).PostLayout +=new EventHandler(Form1_PostLayout);  
     
    void Form1_PostLayout(object sender, EventArgs e)  
    {  
       ChangeDropDownMenu(dockPanel1);  


    Kind regards,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top