SelectedIndexChange without Suggests

2 posts, 0 answers
  1. Shaggy
    Shaggy avatar
    8 posts
    Member since:
    Jul 2013

    Posted 22 Oct 2013 Link to this post

    Hello,

    is there a opportunity to exclude the Suggests from the SelectedIndexChange?

    I want to create a function, which reacts only, when the user really chooses an item by clicking or pressing the enter key. In the moment my function fires every time, when the user goes with the keyboard arrows through the suggested items.

    Maybe theres another way then to react to the SelectedIndexChange?

    Thanks for advices!

    Greets
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 24 Oct 2013 Link to this post

    Hello Zeljko,

    Thank you for writing back.

    Currently, the SelectedIndexChanged event is fired exactly when the user changes the selected item no matter how he does the change and this is the desired behavior for the event.

    In order to achieve the desired scenario you can use the following combination of the SelectedIndexChanged and KeyDown events:
    bool IsArrowkey = false;
     
    void radDropDownList1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
        {
            IsArrowkey = true;
        }
        if (e.KeyCode == Keys.Enter)
        {
            MyFunction();
        }
    }
     
    private void MyFunction()
    {
        Console.WriteLine("MyFuntion");
    }
     
    private void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
    {
        if (!IsArrowkey)
        {
            MyFunction();                   
        }
        IsArrowkey = false;
    }

    I hope this information helps. Should you have any other questions, I will be glad to assist you.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top