DataGridViewComboBoxColumn change事件

  • dataGridView添加EditingControlShowing事件
private void gridSetup_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    try
    {
        if (gridSetup.CurrentCell.OwningColumn.Name == "clmSetupStation")
        {
            //添加TextChanged事件而非SelectedIndexChanged
            ((ComboBox)e.Control).TextChanged += WorkorderSetupForm_TextChanged;
        }
    }
    catch (Exception ex)
    {
        LogHelper.Error(ex.Message + ";" + ex.StackTrace);
        SetStatusLabelText("Remove setup fail", 1);
    }
}
  • WorkorderSetupForm_TextChanged
private void WorkorderSetupForm_TextChanged(object sender, EventArgs e)
{
    try
    {
        ComboBox combox = sender as ComboBox;
        if (combox == null)
        {
            return;
        }

        //MLManager mLHanlder = new MLManager(sessionContext, initModel, this.view);
        DataGridViewRow row = gridSetup.CurrentRow;
        
		//点击目标单元格时可能会触发不需要的事件,需要过滤掉
        if (string.IsNullOrEmpty(station) || station == "System.Data.DataRowView")
        {
            return;
        }

        if (station == row.Cells["clmSetupStation"].Value.ToString())
        {
            return;
        }
        row.Cells["clmSetupStation"].Value = station;
        ((DataGridViewImageCell)row.Cells["clmSetupStaus"]).Value = squareFillCloseImage;
        row.Cells["clmSetupMaterialBinNumber"].Value = "";

    }
    catch (Exception ex)
    {
        LogHelper.Error(ex.Message + ";" + ex.StackTrace);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值