Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataGridView combobox cell event in c#

Tags:

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.

like image 255
Awadhendra Avatar asked Dec 16 '11 06:12

Awadhendra


1 Answers

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

like image 71
Nighil Avatar answered Oct 23 '22 12:10

Nighil