Resolved combobox How to trigger the Enter key event when the Changed event is fired

Anwind

Well-known member
Joined
Nov 6, 2021
Messages
48
Programming Experience
1-3
hello.


How to trigger the Enter key event when the Changed event is fired.

Is the source below correct?


C#:
C# - Datagridview combobox change event

private void dgv_1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{

    ComboBox combo = e.Control as ComboBox;
    if (combo != null)
    {
         combo.SelectedIndexChanged -= new EventHandler(dgv_1_SelectedIndexChanged);
         combo.SelectedIndexChanged += new EventHandler(dgv_1_SelectedIndexChanged);
    }
}
private void dgv_em_1_sovp_SelectedIndexChanged(object sender, EventArgs e)
{
    ComboBox combo = (ComboBox)sender;

    if (combo.SelectedIndex == 0)
    {

    }
    else if (combo.SelectedIndex == 1)
    {

    }
}
 
What do you want to do, exactly?

Expecting an answer like "as soon as the user selects an item from the list I want to move the focus to the next cell on the row"
 
What happens if the user is using a keyboard instead of a mouse? A change event will be fired everytime they arrow up or down through the list. So if you force the user's focus to change, then you just made a horrible user experience.
 
Back
Top Bottom