DX控件高手请帮帮我.gridcontrol 绑定list,关于更改列名,或者隐藏列,谢谢大家
将一个list绑定到gridcontrol上.如果这个list里的某一个属性是一个collection.gridcontrol会自动将这个collection展开为一个新的view,但是这个新的view的列名无法重命名,并且这个view的列名就是改集合里的属性的名称.求教高手,如何重命名子view里的列的名字..代码如下
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
List<stu> lststu = new List<stu>();
lststu.Add(new stu("A","tang"));
gridControl1.DataSource = lststu;
}
}
public class stu
{
private string _classno;
public string Classno
{
get { return _classno; }
set { _classno = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
public stu(string cn,string name)
{
this._classno = cn;
this._name = name;
this.lstchild = new List<hobby>();
this.lstchild.Add(new hobby("1", "ss"));
this.lstchild.Add(new hobby("2","nn"));
}
private List<hobby> lstchild;
public List<hobby> Lstchild
{
get { return lstchild; }
set { lstchild = value; }
}
}
public class hobby
{
private string _id;
public string Id
{
get { return _id; }
set { _id = value; }
}
private string _hobby;
public string Hobby
{
get { return _hobby; }
set { _hobby = value; }
}
public hobby(string id, string hb)
{
this._id = id;
this._hobby = hb;
}
}
再run designer里只能更改班级的名字,但无法更改子view中id列和hobby列的列名.
我希望吧id改成学号,而hobby类里的属性字段不变