DevExpress Grid中实现点击Detail获得Master rowHandle的方法

项目中用到DevExpress的Grid,其中又用到Master-Detail。点击Detail中的行,无法获取所属的Master rowHandle,设置一个属性就可以。假设GridControl下有gridview1,gridview2,其中gridview1是master,gridview2是child。实现代码如下:


private void gridView2_GotFocus(object sender, EventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)gridControl1.FocusedView;
int rowHandle = gv.SourceRowHandle;
gridView1.FocusedRowHandle = rowHandle;
}

你可能感兴趣的:(DevExpress Grid中实现点击Detail获得Master rowHandle的方法)