RadRibbonBar...RadSplitButtonElement: different behavior in different versions

5 posts, 1 answers
  1. Alex
    Alex avatar
    4 posts
    Member since:
    Oct 2017

    Posted 20 Nov 2017 Link to this post

    The following sample code creates a RadRibbonBar\RibbonTab\RadRibbonBarGroup\RadSplitButtonElement UI structure.

    Clicking on the radSplitButtonElement1 button causes the click handler (radSplitButtonElement1_Click) to be called twice.

    Tested in R3 2017. This is not how it worked in Q1 2013, where the handler was called once.

    Is this a bug or an intended change in behavior?

    using System;
    using System.Diagnostics;
    using Telerik.WinControls.UI;
     
    namespace wf7
    {
        public partial class RadForm1 : RadForm
        {
            public RadForm1()
            {
                InitializeComponent();
     
                RadMenuItem mni1 = new RadMenuItem("item1", 1);
                this.radSplitButtonElement1.Items.Add(mni1);
                this.radSplitButtonElement1.DefaultItem = mni1;
                mni1.Click += radSplitButtonElement1_Click;
     
                RadMenuItem mni2 = new RadMenuItem("item2", 2);
                this.radSplitButtonElement1.Items.Add(mni2);
                mni2.Click += radSplitButtonElement1_Click;
            }
     
            private void radSplitButtonElement1_Click(object sender, EventArgs e)
            {
                Debug.Print("invoked menu item");
            }
        }
        partial class RadForm1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
     
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
     
            #region Windows Form Designer generated code
     
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.radRibbonBar1 = new Telerik.WinControls.UI.RadRibbonBar();
                this.ribbonTab1 = new Telerik.WinControls.UI.RibbonTab();
                this.radRibbonFormBehavior1 = new Telerik.WinControls.UI.RadRibbonFormBehavior();
                this.radRibbonBarGroup1 = new Telerik.WinControls.UI.RadRibbonBarGroup();
                this.radSplitButtonElement1 = new Telerik.WinControls.UI.RadSplitButtonElement();
                ((System.ComponentModel.ISupportInitialize)(this.radRibbonBar1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
                this.SuspendLayout();
                //
                // radRibbonBar1
                //
                this.radRibbonBar1.CommandTabs.AddRange(new Telerik.WinControls.RadItem[] {
                this.ribbonTab1});
                //
                //
                //
                this.radRibbonBar1.ExitButton.Text = "Exit";
                this.radRibbonBar1.Location = new System.Drawing.Point(0, 0);
                this.radRibbonBar1.Name = "radRibbonBar1";
                //
                //
                //
                this.radRibbonBar1.OptionsButton.Text = "Options";
                this.radRibbonBar1.Size = new System.Drawing.Size(292, 162);
                this.radRibbonBar1.TabIndex = 0;
                this.radRibbonBar1.Text = "radRibbonBar1";
                //
                // ribbonTab1
                //
                this.ribbonTab1.IsSelected = true;
                this.ribbonTab1.Items.AddRange(new Telerik.WinControls.RadItem[] {
                this.radRibbonBarGroup1});
                this.ribbonTab1.Name = "ribbonTab1";
                this.ribbonTab1.Text = "tab1";
                this.ribbonTab1.UseMnemonic = false;
                //
                // radRibbonFormBehavior1
                //
                this.radRibbonFormBehavior1.Form = this;
                //
                // radRibbonBarGroup1
                //
                this.radRibbonBarGroup1.Items.AddRange(new Telerik.WinControls.RadItem[] {
                this.radSplitButtonElement1});
                this.radRibbonBarGroup1.Name = "radRibbonBarGroup1";
                this.radRibbonBarGroup1.Text = "radRibbonBarGroup1";
                //
                // radSplitButtonElement1
                //
                this.radSplitButtonElement1.ArrowButtonMinSize = new System.Drawing.Size(12, 12);
                this.radSplitButtonElement1.DefaultItem = null;
                this.radSplitButtonElement1.DropDownDirection = Telerik.WinControls.UI.RadDirection.Down;
                this.radSplitButtonElement1.ExpandArrowButton = false;
                this.radSplitButtonElement1.Name = "radSplitButtonElement1";
                this.radSplitButtonElement1.Text = "radSplitButtonElement1";
                this.radSplitButtonElement1.Click += new System.EventHandler(this.radSplitButtonElement1_Click);
                //
                // RadForm1
                //
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(292, 270);
                this.Controls.Add(this.radRibbonBar1);
                this.FormBehavior = this.radRibbonFormBehavior1;
                this.IconScaling = Telerik.WinControls.Enumerations.ImageScaling.None;
                this.Name = "RadForm1";
                //
                //
                //
                this.RootElement.ApplyShapeToControl = true;
                this.Text = "radRibbonBar1";
                ((System.ComponentModel.ISupportInitialize)(this.radRibbonBar1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
                this.ResumeLayout(false);
                this.PerformLayout();
     
            }
     
            #endregion
     
            private RadRibbonBar radRibbonBar1;
            private RadRibbonFormBehavior radRibbonFormBehavior1;
            private RibbonTab ribbonTab1;
            private RadRibbonBarGroup radRibbonBarGroup1;
            private RadSplitButtonElement radSplitButtonElement1;
        }
    }

     

    ddd

  2. Hristo
    Admin
    Hristo avatar
    1261 posts

    Posted 21 Nov 2017 Link to this post

    Hello Alex,

    Thank you for writing.

    The reported behavior is an issue and it is logged on our feedback portal, here: FIX. RadRibbbonBar - the Click event of a RadSplitButtonElement added to the ribbon is fired twice. Your Telerik points have been updated for the report. Additionally, you can subscribe to the item and be updated with all of its status changes. The item will be fixed in the R1 2018 release scheduled for the middle of January.

    Until we permanently resolve the issue you can raise a flag to handle the event only once: 
    bool cancel;
    private void radSplitButtonElement1_Click(object sender, EventArgs e)
    {
        if (!cancel)
        {
            //Handle Click event;
            this.cancel = true;
            return;
        }
     
        this.cancel = false;
    }

    I hope this helps. Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Alex
    Alex avatar
    4 posts
    Member since:
    Oct 2017

    Posted 21 Nov 2017 Link to this post

    Thank you, but this workaround only works if I click on the menu button itself. If I click on the arrow and then on one of the drop-down items, it works every next time only.

    Conversely though, Q1 2013 version also has a bug: when clicking on the arrow and then on one of the drop-down items, it performs the action twice.

  4. Answer
    Hristo
    Admin
    Hristo avatar
    1261 posts

    Posted 22 Nov 2017 Link to this post

    Hi Alex,

    Thank you for writing back.

    You are correct, when you start clicking on the menu items the event will work every other time. Since you are having a default item set to the split button element, you can handle the scenario this way: 
    private void radSplitButtonElement1_Click(object sender, EventArgs e)
    {
        if (sender is RadSplitButtonElement)
        {
            return;
        }
     
        Debug.WriteLine("invoked menu item");
        //Handle Click event;
    }

    I hope this helps. Please let me know if you have other questions.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Alex
    Alex avatar
    4 posts
    Member since:
    Oct 2017

    Posted 22 Nov 2017 Link to this post

    Thanks for this, that works.

    Will now wait for the proper fix in the next Release.

Back to Top