SelectedIndexChanging Event?

Thread is closed for posting
3 posts, 0 answers
  1. SUNIL
    SUNIL avatar
    237 posts
    Member since:
    Jan 2004

    Posted 22 Sep 2010 Link to this post

    Is there any way to implement a 'SelectedIndexChanging' event for a RadComboBox?
    The reason is that I need to cancel the index changed event sometimes, but I cannot since the changing event is missing in RadComboBox.
  2. SUNIL
    SUNIL avatar
    237 posts
    Member since:
    Jan 2004

    Posted 24 Sep 2010 Link to this post

    I was able to extend the radcombobox so that the selectedindexchanging event fires that allows the developer to cancel the selectedindexchanged event.
    This will be useful for developers using Telerik RadControls for Winforms version prior to 2010 Q2.
    The attached project contains an extended custom control that inherits RadComboBox but adds new functionality of selectedindexchanging event.

    The complete code for such a custom control is given below.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
    using Telerik.WinControls;
    namespace MyControls
        public partial class RadComboBoxPlus : RadComboBox
            public event CancelEventHandler SelectedIndexChanging;
            public int PreviousSelectedIndex { get; private set; }
            public RadComboBoxPlus()
                PreviousSelectedIndex = -1;
            public override string ThemeClassName
                    return typeof(RadComboBox).FullName; 
            protected void OnSelectedIndexChanging(CancelEventArgs e)
                var selectedIndexChanging = SelectedIndexChanging;
                if (selectedIndexChanging != null)
                    selectedIndexChanging(this, e);
            protected override void OnSelectedIndexChanged(EventArgs e)
                if (PreviousSelectedIndex != SelectedIndex)
                    var cancelEventArgs = new CancelEventArgs();
                    if (!cancelEventArgs.Cancel)
                        PreviousSelectedIndex = SelectedIndex;
                        SelectedIndex = PreviousSelectedIndex;
            protected override void OnPaint(PaintEventArgs pe)

  3. Peter
    Peter avatar
    1160 posts

    Posted 28 Sep 2010 Link to this post

    Hello Sunil,

    Thanks for the sharing this implementation.

    Your approach is correct. You can also use RadDropDownList that implements this event.
    Do not hesitate to contact us if you have other questions.

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top