winform datagridview中combobox列改变选项时触发其他列变化

2021-06-17 09:05

阅读:502

标签:cts   cte   repo   obj   OWIN   winform   onchange   使用   value   

之前想使用DataGridView的SelectionChanged事件,但是使用了后并没有达到效果

最后使用下面的方式实现:

private void materialCheckGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    int cidx = materialCheckGridView.CurrentCell.ColumnIndex;
    if (materialCheckGridView.Columns[cidx].Name == "ColRetMainDefect")
    {
        //还原控件并绑定事件
        ((ComboBox)e.Control).SelectedIndexChanged += new EventHandler(MaterialCheckForm_SelectedIndexChanged);
    }
}

private void MaterialCheckForm_SelectedIndexChanged(object sender, EventArgs e)
{
    int cindex = materialCheckGridView.CurrentRow.Index;
    if (cindex >= 0)
    {
        int idx = materialCheckGridView.CurrentCell.ColumnIndex;
        if (materialCheckGridView.Columns[idx].HeaderText == "回修主要病疵")
        {
            //int cindex = materialCheckGridView.CurrentCell.RowIndex;
            string defdesc = ProdReportDA.GetDefectsDescription(materialCheckGridView.Rows[cindex].Cells["ColRetMainDefect"].EditedFormattedValue.ToString(), materialCheckGridView.Rows[cindex].Cells["RollId"].Value.ToString());
            materialCheckGridView.Rows[cindex].Cells["ColDefectDesc"].Value = defdesc;
        }
    }
}

 

winform datagridview中combobox列改变选项时触发其他列变化

标签:cts   cte   repo   obj   OWIN   winform   onchange   使用   value   

原文地址:https://www.cnblogs.com/hubbert123/p/10334117.html


评论


亲,登录后才可以留言!