更新时间:2023-11-27 23:26:22
错误是因为您的演员表无法正常工作:
The error is because your cast isn''t working:
(dataGridView1.Columns[4] as DataGridViewComboBoxColumn).DataSource
http://msdn.microsoft.com/en-us/library/cscsdfbt%28v = vs.71%29.aspx [ ^ ]
如果这种类型的转换不起作用,它只会返回null,因此您试图在一个null对象上设置.DataSource
属性.
我不能说为什么强制转换不起作用,但是在强制转换之前,您需要检查dataGridView1.Columns[4]
不为空,并且dataGridView1.Columns[4]
是DataGridViewComboBoxColumn
类型.
http://msdn.microsoft.com/en-us/library/cscsdfbt%28v=vs.71%29.aspx[^]
If this type of cast doesn''t work, it simply returns null, so you''re trying to set the .DataSource
property on an object that is null.
I can''t say why the cast isn''t working but you need to check that dataGridView1.Columns[4]
is not null and that dataGridView1.Columns[4]
is of type DataGridViewComboBoxColumn
before you cast.