我有一个更新包含类型 DataGridViewComboBoxCell 的列的方法,早期 ComboBoxCell 为空,选择产品并在添加新记录时更新 ComboBoxCell 做得很好,但是当我修改它时会发送异常:“DataGridViewComboBoxCell 值无效" 如果您在重新分配 DataSource 属性时是这样,则不会。
这里的方法:
private void CargarTipoGasto(ref DataGridViewComboBoxCell ComboColumn)
{
ComboColumn.DataSource = from oPro in dtContext.tblProducto
where oPro.ProductoId == objProducto.ProductoId
from oMat in dtContext.tblMatrizDeCuentasGD
where oMat.Partida.Substring(0,3) ==
oPro.tblObjetoGasto.ObjetoGastoId.Substring(0,3)
from oTipGas in dtContext.tblTipoGasto
where oMat.TipoGasto == oTipGas.TipoGastoId
select oTipGas;
ComboColumn.ValueMember = TIPOGASTO_ID;
ComboColumn.DisplayMember = TIPOGASTO_VALOR;
}
verique 没有空值,引用很好
非常感谢您的帮助