This is a migrated thread and some comments may be shown as answers.

SelectedIndexChange without Suggests

1 Answer 45 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Shaggy
Top achievements
Rank 1
Shaggy asked on 22 Oct 2013, 06:22 AM
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

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 24 Oct 2013, 12:45 PM
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 >>
Tags
DropDownList
Asked by
Shaggy
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or