0

我创建了一个datatablein 代码并将其设置为gridcontrol( DevExpress component) 以像此处的代码一样显示它(添加一行datatable并将其设置为datasourceof gridcontrol):

DataTable PersonFamiliesDataTable = new DataTable();

PersonFamiliesDataTable.Columns.Add("BirthDate", typeof(String));
PersonFamiliesDataTable.Columns.Add("Job", typeof(String));
PersonFamiliesDataTable.Columns.Add("NameFamily", typeof(String));

DataRow PersonFamilyRow = PersonFamiliesDataTable.NewRow();

PersonFamilyRow["BirthDate"] = DateTimePicker_FamilyInfo_BirthDate.Text;
PersonFamilyRow["Job"] = FamilyInfo_txt_job.Text;
PersonFamilyRow["NameFamily"] = FamilyInfo_txt_NameFamily.Text;
PersonFamiliesDataTable.Rows.Add(PersonFamilyRow);

grid_Family.DataSource = PersonFamiliesDataTable;

用户可以更改我的gridcontrol. 我想将我的gridcontrol更新更改为我的datatable. 我该怎么做(行编辑,行删除)?

4

1 回答 1

0

我找到了解决方案:在Family_gridView_CellValueChanged事件中,添加以下代码:

PersonFamiliesDataTable = (DataTable)grid_Family.DataSource;

因此,在网格单元格发生任何更改后,我datatable正在更新。请注意,当用户更改单元格并焦点离开它时,会出现此事件。

于 2012-06-14T16:11:31.217 回答