我意识到DevExpress GridLookUpEdit编辑器并不是为处理具有多部分键的数据而设计的。但是,无论如何我都在尝试解决这个限制。
我的GridLookUpEdit的数据是Product-Purity,有两列"PRODUCT_ID“和"PURITY_ID”。当用户在GridLookupEdit中选择product-purity行时,我使用以下代码设置底层网格的纯度:
void lookUpEditProductPurities_EditValueChanged(object sender, EventArgs e)
{
// Get the purity from the product selected and update the purity column of the grid.
DevExpress.XtraEditors.GridLookUpEdit editor = (sender as DevExpress.XtraEditors.GridLookUpEdit);
DevExpress.XtraGrid.Views.Grid.GridView view = editor.Properties.View as DevExpress.XtraGrid.Views.Grid.GridView;
object val = view.GetRowCellValue(view.FocusedRowHandle, "PURITY_ID");
if (editor.Parent is GridControl)
{
GridControl ParentGridControl = (editor.Parent as GridControl);
GridView ParentGridView = (ParentGridControl.MainView as GridView);
DataRow CurrentDataRow = ParentGridView.GetDataRow(ParentGridView.FocusedRowHandle);
CurrentDataRow["PRODUCT_PURITY_ID"] = val;
}
}当我在主网格中使用它时,它工作得很好,但有一个小问题。当现有行引用的纯度不是产品的第一纯度时,弹出网格将使其看起来就像选择了第一纯度一样。在我看来,这不是什么大问题。
但是:我遇到的一个大问题是,当我在主-细节网格的细节行中使用这个GridLookUpEdit时。调用: editor.Parent返回主节点的网格控制,ParentGridControl.MainView返回主节点的GridView。
如何获取GridLookUpEdit作为编辑器的gridView -子gridView??
蒂娅-
发布于 2011-11-17 13:09:33
您的任务(获取详细视图)可以使用What can cause the properties, methods, and events of a detail grid view to fail?文章中所示的方法--使用GridView.GetDetailView方法来实现。
另请查看以下文章:Navigating Through Master and Detail Rows
https://stackoverflow.com/questions/8157181
复制相似问题