Awadhendra
Awadhendra

Reputation: 513

DataGridView combobox cell event in c#

I want to display a message when items in DataGridViewComboBox has been changed. I am able to perform it partially by taking help of datagridview CellbeginEdit event and CellEndEdit event but that is not up to mark. I want it as it happen in combobox selection change event.

I had google it for solving but not get appropriate help.

Any help will be appriciated.

Upvotes: 6

Views: 8380

Answers (1)

Nighil
Nighil

Reputation: 4129

use EditingControlShowing event for it

private void grvList_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
             if (grvList.Columns[grvList.CurrentCell.ColumnIndex].Name.Equals("routing_ID"))
                {
                    ComboBox cmbprocess = e.Control as ComboBox;
                    cmbprocess.SelectedIndexChanged += new EventHandler(grvcmbProcess_SelectedIndexChanged);
                }
        }


 private void grvcmbProcess_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cmbprocess = (ComboBox)sender;
            if (cmbprocess.SelectedValue != null)
            {
               /// Your Code goes here
            }

        }

this is only an example program to show how to do it

Upvotes: 8

Related Questions