如何通过双击从devexress gridcontrol的详细信息行获取数据。如果我关注的是子行,网格视图的双击事件就不能捕捉到。
我尝试过这种方法,但我的请求是通过双击来捕获数据
private void gcOperasyonlar_FocusedViewChanged(object sender, DevExpress.XtraGrid.ViewFocusEventArgs e)
{
if (e.View != null && e.View.IsDetailView)
(e.View.ParentView as GridView).FocusedRowHandle = e.View.SourceRowHandle;
GridView detailView = gcOperasyonlar.FocusedView as GridView;
MessageBox.Show(detailView.GetFocusedRowCellValue("Kalip").ToString());
}谢谢你的帮忙
发布于 2014-06-20 16:52:25
还有一种更简单的方法:
ColumnView cv = _gridControlxyz.FocusedView as ColumnView;
selectedRow row = cv.GetRow(cv.FocusedRowHandle)发布于 2013-12-29 05:03:15
我在论坛上找到了这段代码,只要你的网格是不可编辑的(这样鼠标点击就不会激活可编辑字段),它就会很有用。
private void gridView1_DoubleClick(object sender, EventArgs e) {
GridView view = (GridView)sender;
Point pt = view.GridControl.PointToClient(Control.MousePosition);
DoRowDoubleClick(view, pt);
}
private static void DoRowDoubleClick(GridView view, Point pt) {
GridHitInfo info = view.CalcHitInfo(pt);
if(info.InRow || info.InRowCell) {
string colCaption = info.Column == null ? "N/A" : info.Column.GetCaption();
MessageBox.Show(string.Format("DoubleClick on row: {0}, column: {1}.", info.RowHandle, colCaption));
}
}http://www.devexpress.com/Support/Center/Question/Details/A2934
发布于 2013-12-31 20:00:49
假设您有两个网格视图(我猜您在网格控件中使用了网格视图):gvMaster和gvDetail。
您应该为gvDetail实现event DoubleClick,以实现所需的功能:
private void gvDetail_DoubleClick(object sender, EventArgs e) {
var gv = sender as GridView; // sender is not gvDetail! It's an instance of it. You have as many as there are rows in gvMaster
var row = gv.GetDataRow(e.FocusedRowHandle); // or use gv.GetRow(e.FocusedRowHandle) if your datasource isn't DataSet/DataTable (anything with DataRows in it)
MessageBox.Show(row["Kalip"].ToString());
}https://stackoverflow.com/questions/20819290
复制相似问题