我在c#winforms上遇到了奇怪的错误。我将逐步总结问题。
在System.RuntimeType处。 ThrowIfTypeNeverValidGenericArgument(RuntimeType类型) SanityCheckGenericArguments(RuntimeType [] genericArguments,RuntimeType [] genericParamters) MakeGenericType(Type []实例化)
,位于System.Windows.Forms.BindingSource。 CreateBindingList(类型类型) GetListFromType(类型类型) ResetList() System.ComponentModel.ISupportInitialize.EndInit()
(System.ComponentModel.ISupportInitialize)(this.tankModelBindingSource).EndInit();
我不做任何更改就关闭了它们并重新打开winform.cs(设计器)
错误消失了!
我想念什么吗?每次我都要得到这个错误吗?这是一个错误吗?
谢谢。
public void datagridFixedItemVisualization()
{
fixedItemModelBindingSource.DataSource = MainParticularsModel.FixedItemList;
}
private void dgTankSet_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
// CALCULATING....
dgTankSet.DataSource = MainParticularsModel.TankList;
dgTankSet.Refresh();
}
private void cmbCatFilter_SelectedIndexChanged(object sender, EventArgs e)
{
CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dgTankSet.DataSource];
currencyManager1.SuspendBinding();
TankCategory cmbfiltername = (TankCategory)Enum.Parse(typeof(TankCategory), cmbCatFilter.SelectedItem.ToString());
switch (cmbfiltername)
{
case TankCategory.ALL:
makeALLrowsVisible();
currencyManager1.ResumeBinding();
break;
case TankCategory.ETC:
makeALLrowsVisible();
foreach (DataGridViewRow row in dgTankSet.Rows)
{
if (row.Cells[0].Value.ToString() != "ETC")
{
row.Visible = false;
}
}
currencyManager1.ResumeBinding();
break;
}
}
private void btnAddFixedItem_Click(object sender, EventArgs e)
{
using (FixedItemForm frm = new FixedItemForm() {FixedItemInfo=new FixedItemModel() })
{
if (frm.ShowDialog() == DialogResult.OK)
{
MainParticularsModel.FixedItemList.Add(frm.FixedItemInfo);
fixedItemModelBindingSource.ResetBindings(false);
fixedItemModelBindingSource.DataSource = MainParticularsModel.FixedItemList;
dgFixedItems.Update();
dgFixedItems.DataSource = fixedItemModelBindingSource;
}
}
}