Dropdown event that reacts only to user actions?

4 posts, 0 answers
  1. Grant Fish
    Grant Fish avatar
    10 posts
    Member since:
    Apr 2010

    Posted 29 Jul 2014 Link to this post

    We have been using the SelectedIndexChanged event to react to user selections in dropdowns. The problem is that this event also fires when the DataSource is set, when the user is using the arrow keys to browse through the dropdown items, and when different items are selected using AutoComplete. Quite often, changing a dropdown selection can trigger a long and expensive process of database calls and changes to other controls.

    I would like to use an event that only fires when the user has truly made a selection. We have been handling this problem by either setting module-level flags to ignore the SelectedIndexChanged event, or temporarily disconnecting the event handler.

    Is there a different event that will fire only for actual user interaction? The Windows Forms combo box has a SelectionChangeCommitted event that looks better for this purpose, but I don't see an equivalent event for the Telerik dropdown.
  2. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 01 Aug 2014 Link to this post

    Hello Grant,

    Thank you for writing.

    In this case we cannot determine when the user has truly made a change or is just pressing the arrows numerous times. The SelectionChangeCommitted event fires only when the selected item is changed by the user, but I don't think that it can determine when the user is making a real choice or not. The case where the index is changed programmatically can be easily avoided by just using a flag or unsubscribing and then subscribing to the event. So there is no better event that can be currently used. 

    If you have any other questions, please do not hesitate to contact us.

    Regards,
    Dimitar
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Grant Fish
    Grant Fish avatar
    10 posts
    Member since:
    Apr 2010

    Posted 01 Aug 2014 in reply to Dimitar Link to this post

    Are you saying that I should see a SelectionChangeCommitted event? I see no such event in the Telerik.WinControls.UI.RadDropDownList control (Q1 2014 version).

    SelectionChangeCommitted, as defined in the standard Windows combo box, would be pretty close to what I need, other than firing as the user browses the list. It would certainly be a lot closer that SelectedIndexChanged, but I don't see that SelectionChangeCommitted is available.
  5. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 05 Aug 2014 Link to this post

    Hello Grant,

    Thank you for writing back.

    I was pointing the SelectionChangeCommitted in the default .NET control. To replicate the same behavior with our RadDropDownList you can use a simple flag:
    bool isIndexChagedByCode;
    void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
    {
        if (!isIndexChagedByCode)
        {
            Console.WriteLine("Index changed by user");
        }
        else
        {
            Console.WriteLine("Index changed by code");
        }
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        isIndexChagedByCode = true;
        radDropDownList1.SelectedIndex = 5;
        isIndexChagedByCode = false;
    }

    I hope this helps. Should you have any other questions do not hesitate to ask.
     
    Regards,
    Dimitar
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top