实现效果
打开设计器 找到CellValueChanged事件
编写代码
private void gvmain_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
string seq = gvmain.GetRowCellValue(e.RowHandle, colQaSeq).ToString();
QualityInfo item = dataInfo.Find(x => x.Seq.ToString() == seq);
//匹配是否存在栈板号,不存在则报错,存在则匹配对应id
if (!_ListPalletNum.Select(b => b.PALLET_NUMBER).Contains(item.pallet_number))
{
MessageBox.Show($"该工单不存在 {item.pallet_number}栈板号,请重新填写", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
dataInfo[e.RowHandle].pallet_number = string.Empty;
}
else
{
dataInfo[e.RowHandle].pallet_numberid = _ListPalletNum.First(b => b.PALLET_NUMBER == item.pallet_number).ID;
}
}
标签:GridView,dataInfo,seq,Devexpress,单元格,number,pallet,item,RowHandle
From: https://www.cnblogs.com/wofeiliangren/p/18165302