绑定数据:
父表:
DataTable _parent = _dvFlt.ToTable().Copy();
子表:
DataTable _child = _dvLog.ToTable().Copy();
关联:
DataSet _ds = new DataSet();
_ds.Tables.Add(_parent);
_ds.Tables.Add(_child); DataRelation _dr = new DataRelation("", _ds.Tables[0].Columns["flight_id"], _ds.Tables[1].Columns["ref_keys"], false);
_ds.Relations.Add(_dr); dgInfo.DataSource = _ds.Tables[0];
主表加载事件:
private void dgInfo_DataSourceChanged(object sender, EventArgs e)
{ GridColumnCollection gridColumns = this.gridView1.Columns;
foreach (GridColumn item in gridColumns)
{ }
}
子表加载事件:
private void GridView1_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e)
{
GridView detailView = gridView1.GetDetailView(e.RowHandle, e.RelationIndex) as DevExpress.XtraGrid.Views.Grid.GridView;
detailView.CustomColumnDisplayText += DetailView_CustomColumnDisplayText;
GridColumnCollection gridColumns = detailView.Columns;
foreach (GridColumn item in gridColumns)
{
}
}
改变事件格式:
item.DisplayFormat.FormatString = "MM-dd";
item.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;