- - PR -
マスター/詳細の3階層構造で表示を連動したいのですが
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2005-06-22 13:03
VS.NET2003 Windows/C#です。
Windows.Form/DataGridを使いマスター/詳細の関係をさらに階層を深めようとしています。 例えば、親、子、孫と3階層の関係をデータセットに記述して準備し、親子のフォームと子孫のフォームを開いておいて親や子の行カーソルを動かすと孫まで連動する仕組みにしたいのですが、子孫の関係がうまく機能しません。 仕組みを単純化して示すと次のようになります。 DataSetに含むもの ・ParentTable ・ChildTable ・GrandChildTable ・ParentToChildRelation ・ChildToGrandChildRelation 1) ParentTableを表示するDataGridでは DataView parentDataView = dataSet.Tables[ParentTable] as DataView; parentDataGrid.DataSource = parentDataView; CurrencyManager parentCM = BindingContext[parentDataView] as CurrencyManager; 2) ChildTableを表示するDataGirdでは childDataGrid.SetDataBinding(parentDataView, ParentToChildRelation); CurrencyManager childCM = BindingContext[parentDataView, ParentToChildRelation] as CurrencyManager; DataView childDataView = dataSet.Tables[ChildTable] as DataView; 3) GrandChildTableを表示するDataGridでは grandChildDataGrid.SetDataBinding(childDataView, ChildToGrandChildRelation); CurrencyManager grandChildCM = BindingContext[childDataView, ChildToGrandChildRelation] as CurrencyManager; 2)のところでChildTableのchi.dDataViewを取得してgrandChildDataGridにバインドしているのがうまく機能しないようで、親や子の行カーソルを動かしても孫が初期(先頭)のままで反応しません。このようにDataGridのDataSourceを指定する変わりにリレーションを使ってSetDataBinding()で指定した場合にはchildDataViewは何か別の方法で取得する必要があるのでしょうか? とりあえずは上述のような仕組みを前提にしての話になりますが、何かご存知でしたらご教示いただければとよろしくお願いします。 |
1