gökhan
gökhan

Reputation: 13

Getting data from detail row

How can i get data from devexress gridcontrol's detail row via double-click. If i focused on child row gridview's double click event doesn't catch.

i tried this method, but my request is catching data by double click

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());  
        }

thanks for your help

Upvotes: 0

Views: 4222

Answers (3)

frankey
frankey

Reputation: 19

There is also an easier way:

ColumnView cv = _gridControlxyz.FocusedView as ColumnView;

selectedRow row = cv.GetRow(cv.FocusedRowHandle)

Upvotes: 1

Marko Juvančič
Marko Juvančič

Reputation: 5890

Let's say you have two gridviews (I'm guessing you're using gridviews in your grid control): gvMaster and gvDetail.

You should implement event DoubleClick for your gvDetail in order to achieve desired functionality:

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()); 
}

Upvotes: 0

Vland
Vland

Reputation: 4272

I found this code on the forum, It might be useful as long as your grid is not editable (so that mouse click doesn't activate the editable field).

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

Upvotes: 0

Related Questions