このグリッドの親はプロジェクトですが、子はBOMです。次のコードを使用して子グリッドを表示することができました。子グリッドビューから列を削除する
private void gridView_MasterRowEmpty(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowEmptyEventArgs e)
{
Project projects = (Project)gridView.GetRow(e.RowHandle);
e.IsEmpty = projects.BOMs.Count == 0;
}
private void gridView_MasterRowGetRelationCount(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetRelationCountEventArgs e)
{
e.RelationCount = 1;
}
private void gridView_MasterRowGetRelationName(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetRelationNameEventArgs e)
{
e.RelationName = "BOMs";
}
private void gridView_MasterRowGetChildList(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetChildListEventArgs e)
{
Project projects = (Project)gridView.GetRow(e.RowHandle);
e.ChildList = new BindingSource(projects, "BOMs");
}
ただし、コードはすべての列を表示しています。私は子供からいくつかの列、すなわちBOMを隠したいと思います。
私が見つけた唯一の方法は
dataGridView1.Columns[index].Visible = false;
以下のようなものを使用することでした。しかし、私は上記のコードをどこに置くべき?
更新されたコード
private void gridView_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e)
{
GridView gridView = sender as GridView;
GridView detailView = (GridView)gridView.GetDetailView(e.RowHandle, e.RelationIndex);
detailView.Columns["Column Name"].Visible = false;
}
あなたの答えをありがとう。あなたの答えは私に方向性を与えました。しかし、私はそれにいくつかの変更を加えました。更新されたコードを確認してください。 – active92