When i am adding eventHandler on combo in datagridview, its adding eventHandler to all other combo o

Posted by Rajesh Rolen- DotNet Developer on Stack Overflow See other posts from Stack Overflow or by Rajesh Rolen- DotNet Developer
Published on 2010-06-07T09:30:06Z Indexed on 2010/06/07 9:32 UTC
Read the original article Hit count: 302

Filed under:
|

i am using VS2005 (c#.net desktop application). when i am adding eventHandler to a combo of datagridview, its automatically adding same eventhandler to all other combos of same datagridview..

my code:

private void dgvtstestdetail_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {

        DataGridView grid = (sender as DataGridView);



        if (grid.CurrentCell.OwningColumn == grid.Columns["gdvtstd_TestParameter"])
        {

            ComboBox cb = (e.Control as ComboBox);
            cb.SelectedIndexChanged -= new EventHandler(dvgCombo_SelectedIndexChanged);
            cb.SelectedIndexChanged += new EventHandler(dvgCombo_SelectedIndexChanged);

        }
 }

© Stack Overflow or respective owner

Related posts about c#

Related posts about datagridview