更新时间:2022-05-02 02:48:14
您尚未告诉DataGridViewColumn要绑定的内容.
You haven't told the DataGridViewColumn what to bind to.
通常,您绑定到绑定数据类型的公共属性.在这种情况下,您的数据类型为 long
,该数据类型没有要绑定的适当属性.
Normally you bind to a public property of the bound data type. In this case your data type is long
which does not have an appropriate property to bind to.
将您的 long
包装在自定义类中,并将其公开为公共属性.
Wrap your long
in a custom class and expose it as a public property.
public class Data
{
public long Value { get; set; }
}
将列绑定到 Value
属性.您可以在设计器中执行此操作,但这是代码:
Bind your column to the Value
property. You can do this in the designer, but here is the code:
Column1.DataPropertyName = "Value";
现在使用 Data
代替 long
:
ProjectIDs = new BindingList<Data>();
...
long temp = long.Parse(textBox1.Text);
ProjectIDs.Add(new Data { Value = temp });