AcceptButton + CancelButton support in UserDockControl?

5 posts, 1 answers
  1. Ben
    Ben avatar
    28 posts
    Member since:
    Dec 2007

    Posted 04 May 2009 Link to this post

    Hi,

    I have an application with multiple docked/tabbed panels. I also launch some panels as floating windows. All my panels derive from UserDockControl.

    On certain panels I have OK/Cancel buttons which commit changes to the database, or cancel them. I would like to implement support for firing these buttons if/when the user hits Enter/Esc on their keyboard.

    This is handled in normal WinForms via the AcceptButton and CancelButton properties of a Form. I see these properties exist for UserDockForm as well, however if I try deriving my panels from UserDockForm I get behaviour I am not happy with - i.e. I can't seem to launch the panels as floating.

    Is there a way to implement the AcceptButton/CancelButton support in a panel derived from UserDockControl? 

    What is the difference between UserDockControl and UserDockForm?

    Thanks in advance,
    Ben
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 07 May 2009 Link to this post

    Hi Ben,

    This functionality is not automatically managed for current version of DockingManager component. This is a good idea and we have logged it for research and possible implementation in the new RadDock component.

    To support this behavior in floating mode you can try this snippet:

    UserDockForm dockPanel = new UserDockForm(); 
    this.dockingManager1.SetDock(dockPanel, DockPosition.Left); 
    this.dockingManager1.Float(dockPanel); 
     
    if (dockPanel.DockingSite.HostForm != null
        dockPanel.DockingSite.HostForm.AcceptButton = dockPanel.AcceptButton; 
        dockPanel.DockingSite.HostForm.CancelButton = dockPanel.CancelButton; 

    The difference between UserDockForm and UserDockControl is only in the base class corresponding to Form and UserControl objects.

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ben
    Ben avatar
    28 posts
    Member since:
    Dec 2007

    Posted 07 May 2009 Link to this post

    Thanks Julian - that has done the trick!
  5. Ben
    Ben avatar
    28 posts
    Member since:
    Dec 2007

    Posted 06 Jul 2009 Link to this post

    I have just downloaded the 2009 Q2 update and am trying to update my existing code. I can't find a way to implement this functionality in the new controls. Can you advise how I set the Accept and Cancel buttons?
  6. Answer
    Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 07 Jul 2009 Link to this post

    Hello Ben,

    For the new RadDock component, you can use following snippet:

    Form myForm = new Form(); 
    HostWindow hostWindow = radDock1.DockControl(myForm, (DockWindow)null, DockPosition.Left);  //for Q2 2009 SP1 release can use also 'radDock1.DockControl(myForm, DockPosition.Left)' 
    radDock1.FloatWindow(hostWindow); 
    myForm.Show();      //this will be not needed for Q2 2009 SP1 release 
     
    if (hostWindow.FloatingParent != null
        hostWindow.FloatingParent.AcceptButton = ((Form)hostWindow.Content).AcceptButton; 
        hostWindow.FloatingParent.CancelButton = ((Form)hostWindow.Content).CancelButton; 
    }  

    Best wishes,
    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