RibbonBar RasSplitButtonElement behaviour

3 posts, 1 answers
  1. AccSys
    AccSys avatar
    9 posts
    Member since:
    May 2011

    Posted 12 Mar 2012 Link to this post

    Hi All,

    I've got a WinForms app with a RadRibbonBar and various groups of buttons, which all work fine ... apart from one.  I've just added a Split button as I need to have additional options when "Previewing", but don't seem to be able to use the main button part as a normal Click event, without the sub-items showing, and clicking on the "Arrow" to show sub-items causes a click event on the main button as well.

    Is there a way to stop the RadSplitButton from showing the dropdown of child items when clicking the "main surface" of the button (as this would be the normal action), and then ONLY show the sub-item collection when you click on the Arrow, as with Microsoft behaviour for the Ribbon Bar?

    Thanks in advance,
    Paul
  2. Answer
    AccSys
    AccSys avatar
    9 posts
    Member since:
    May 2011

    Posted 12 Mar 2012 Link to this post

    For the benefit of anyone else who's having a similar issue, I've managed to sort this out now.  It's a bit of a workaround in places, but does the job.

    You firstly need to manually bind to the events for ActionButton and ArrowButton:

    ID_RIBBON_PREVIEW.ActionButton.Click += new EventHandler(ID_RIBBON_PREVIEW_Click);
    ID_RIBBON_PREVIEW.ArrowButton.Click += new EventHandler(ID_RIBBON_PREVIEW_OPTION_Click);
    ID_RIBBON_PREVIEW.DropDownOpening += new CancelEventHandler(ID_RIBBON_PREVIEW_DropDownOpening);

    Then in the DropDownOpening() event use the following (more verbose than it needs to be):

    void ID_RIBBON_PREVIEW_DropDownOpening(object sender, CancelEventArgs e)
    {
        bool bArrowClicked = ((RadSplitButtonElement)sender).ArrowButton.IsPressed;
         
        if (!bArrowClicked)
            e.Cancel = true;
    }

    So unless you click the "Arrow" the dropdown menu isn't shown.

    Hope this helps others :)
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Mar 2012 Link to this post

    Hi,

    I am writing to confirm that this is the correct approach to achieve the desired functionality. I am marking your post as an answer.
     
    Regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top