C#初学者,今天做项目的时候遇到“未将对象引用设置到对象的实例”
try
{
ComboBox statusComboBoxColumn = sender as ComboBox;
object preStatus = chulaigaodgv.CurrentRow.Cells[4].Value;
string preStatusValue = (preStatus == null) ? string.Empty : preStatus.ToString();
string selectedStatusValue = statusComboBoxColumn.GetItemText(statusComboBoxColumn.Items[statusComboBoxColumn.SelectedIndex]);
if (preStatusValue != selectedStatusValue)
{
DataGridViewComboBoxCell comboCell = new DataGridViewComboBoxCell();
comboCell = (DataGridViewComboBoxCell)chulaigaodgv.CurrentRow.Cells[5];
comboCell.Value = "";
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
贴上代码