DataGrid与bindingSource绑定,bindingSource是数据源是强类型的实体类集合,如何控制datagrid中显示的列??
public SSOHeaderLForm(){
InitializeComponent();
this.bindingSource1.DataSource =typeof (DataCollection <SSOHeader > ) ;
//DataCollection <SSOHeader > 是类SSOHeader的集合
this.dataGrid1.DataSource = this.bindingSource1;
this.Input = new DataCollection<SSOHeader >();
}
#region Input
public override object Input
{
get
{
object val;
if (this.bindingSource1.DataSource is DataCollection<SSOHeader>)
val = this.bindingSource1.DataSource;
else
val = default(DataCollection<SSOHeader>);
return val;
}
set
{
this.bindingSource1.DataSource = typeof(DataCollection<SSOHeader>);
if (value is DataCollection<SSOHeader>)
this.bindingSource1.DataSource = value;
}
}
#endregion
/// <summary>
/// 刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem2_Click(object sender, EventArgs e)
{
Where w = new Where();
w.Add("OrderStatus", "确认");
this.Input = this.getProxy().Find(w);//返回一个SSOHeader的集合
}
问题是我想在datagrid中只想显示SSOHeader类的ID属性。。。。。。
求大神帮忙 --------------------编程问答-------------------- 自己添加一个列就行了,设置字段为ID
http://hi.baidu.com/xiaofeng_1/blog/item/6bb99e5c35ccc349faf2c0f6.html --------------------编程问答--------------------
你搞错了,我说的是datagrid,不是datagridview.是在.net2.0中,在winform中的
补充:.NET技术 , C#