通过列视图在网格控件中添加行。但它没有用。即使我提供了正确的信息。
private void Home_Load(object sender, EventArgs e)
{
int counter;
readStudent();
ColumnView view = gridControl1.FocusedView as ColumnView;
foreach (PAT p in pt_list)
{
String s1 = p.name;
view.AddNewRow(); //Problem here:not adding row
int count = view.RowCount-1;
view.SetRowCellValue(view.GetRowHandle(count), "PAT Name", s1);
foreach(Student1 student in st_lst)
{
counter = 1;
foreach (Allocate al in al_list) {
if (p.ID == al.AID && student.UOB == al.AUOB)
{
String s = student.name;
view.SetRowCellValue(view.GetRowHandle(count), "Student "+ counter, s);
counter++;
}
}
}
gridControl1.DataSource = view;
}
任何人都可以帮助我
答案 0 :(得分:0)
我认为这仍然有效,但您无法将GridView
用作gridControl1.DataSource
。这必须是数据构造,而不是GridControl本身的子部分。因此,使用对象列表或DataTable作为dataSource,并在那里添加新学生。
有关如何绑定对象列表的信息,请参阅the DevExpress help。