public void ModifyGridViewInstance(ExpressApp.MasterDetail.Win.IMasterDetailColumnView masterGridView, int rowHandle, int relationIndex, IModelListView masterModelListView, List <MasterDetailRuleInfo> masterDetailRules) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(masterModelListView, masterGridView, masterDetailRules); bool isRelationSet = modelDetailRelationCalculator.IsRelationSet(rowHandle, relationIndex); if (isRelationSet) { IModelListView childModelListView = modelDetailRelationCalculator.GetChildModelListView(rowHandle, relationIndex); Window window = _xafApplication.CreateWindow(TemplateContext.View, null, true, false); ListView listView = GetListView(modelDetailRelationCalculator, rowHandle, relationIndex, childModelListView); var detailXafGridView = (ExpressApp.MasterDetail.Win.IMasterDetailColumnView)masterGridView.GetDetailView(rowHandle, relationIndex); ((IColumnViewEditor)listView.Editor).CustomGridViewCreate += (o, eventArgs) => { ((IColumnViewEditor)o).DataSource = detailXafGridView.DataSource; eventArgs.Handled = true; eventArgs.GridView = (DevExpress.XtraGrid.Views.Base.ColumnView)detailXafGridView; eventArgs.GridControl.DataSource = detailXafGridView.DataSource; }; EventHandler[] listViewOnControlsCreated = { null }; listViewOnControlsCreated[0] = (sender, args) => { detailXafGridView.MasterFrame = masterGridView.MasterFrame ?? _masterFrame; detailXafGridView.Window = window; detailXafGridView.GridControl = masterGridView.GridControl; listView.ControlsCreated -= listViewOnControlsCreated[0]; }; listView.ControlsCreated += listViewOnControlsCreated[0]; ((PropertyCollectionSource)listView.CollectionSource).MasterObject = masterGridView.GetRow(rowHandle); window.SetView(listView); } }
DevExpress.XtraGrid.Views.Base.ColumnView GetLevelDefaultViewCore(IModelListView masterModelListView, ExpressApp.MasterDetail.Win.IMasterDetailColumnView masterGridView, int rowHandle, int relationIndex, List <MasterDetailRuleInfo> masterDetailRules) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(masterModelListView, masterGridView, masterDetailRules); bool isRelationSet = modelDetailRelationCalculator.IsRelationSet(rowHandle, relationIndex); if (isRelationSet) { IModelListView childModelListView = modelDetailRelationCalculator.GetChildModelListView(rowHandle, relationIndex); ListView listView = GetListView(modelDetailRelationCalculator, rowHandle, relationIndex, childModelListView); DevExpress.XtraGrid.Views.Base.ColumnView defaultXpandXafGridView = null; EventHandler[] listViewOnControlsCreated = { null }; ListView view = listView; listViewOnControlsCreated[0] = (sender, args) => { defaultXpandXafGridView = ((IColumnViewEditor)((ListView)sender).Editor).GridView; view.ControlsCreated -= listViewOnControlsCreated[0]; }; listView.ControlsCreated += listViewOnControlsCreated[0]; listView.CreateControls(); return(defaultXpandXafGridView); } return(null); }
public DevExpress.XtraGrid.Views.Base.ColumnView GetLevelDefaultView(ExpressApp.MasterDetail.Win.IMasterDetailColumnView masterGridView, int rowHandle, int relationIndex, IModelListView masterModelListView, List <MasterDetailRuleInfo> masterDetailRules) { return(GetLevelDefaultViewCore(masterModelListView, masterGridView, rowHandle, relationIndex, masterDetailRules)); }