【发布时间】:2012-07-09 11:19:03
【问题描述】:
我有一个简单的 C# Windows 窗体应用程序,它应该显示一个 DataGridView。作为 DataBinding,我使用了一个对象(选择了一个名为 Car 的类),它看起来像这样:
class Car
{
public string color { get; set ; }
public int maxspeed { get; set; }
public Car (string color, int maxspeed) {
this.color = color;
this.maxspeed = maxspeed;
}
}
但是,当我将 DataGridView 属性 AllowUserToAddRows 设置为 true 时,仍然没有小 * 允许我添加行。
有人建议将carBindingSource.AllowAdd 设置为true,但是,当我这样做时,我得到一个MissingMethodException,它说找不到我的构造函数。
【问题讨论】:
-
我认为你需要一个无参数构造函数(因为没有信息可以传递给你的 2 参数构造函数),那么你是如何绑定它的?
-
我必须在绑定源上使用 AllowNew。
标签: c# datagridview