0
votes

I manage to create master-detail, which shown at the attachment image. the gridControl1 consist of 2 grid view, MainView : gridView1 (which is the master table : data table name : tableSalesOrder) and InfoDetails (Level1) : gridView2 (which is the detail table : data table name : tableDetail).

Both below code are successful for the double clicks event.

 gridView1.DoubleClick += gridView1_DoubleClick;
 gridView2.DoubleClick += gridView2_DoubleClick;

My issue : -

The below code is successful as my gridView1.FocusedColumn.FieldName == "ItemCode".

    private void gridView1_DoubleClick(object sender, EventArgs e)
    {
        object obj;
        string code;
        if (gridView1.FocusedColumn.FieldName == "ItemCode")
        {
            obj = gridView1.GetFocusedRowCellValue("ItemCode");
            if (obj == null) return;
            code = obj.ToString();
            PromptItemForm(code);
        }
    }

But when i try on gridView2_DoubleClick (which for the detail grid view section), my gridView2.FocusedColumn.FieldName == "DocNo" or gridView2.GetFocusedRowCellValue("DocNo") unable to get the value at the detail grid section. It only keep show the ItemCode only, how to get the value for below 2 procedure at the detail grid view section?

  gridView2.FocusedColumn.FieldName == "DocNo"
  gridView2.GetFocusedRowCellValue("DocNo")

I have google the whole night still not able find any hint yet. Need the master assistance. Thank you,

The data set and data table, I done the link by below the code

                 orderData.Tables.Add(tableSalesOrder);
                 orderData.Tables.Add(tableDetail);
                 orderData.Relations.Add("InfoDetails", tableSalesOrder.Columns["ItemCode"], tableDetail.Columns["ItemCode"]);
                 DataRelation orderRelation = orderData.Relations["InfoDetails"];
                 gridControl1.DataSource = tableSalesOrder;
                 gridControl1.ShowOnlyPredefinedDetails = false;

the code for the check the gridView2 column name and value, i code as below

          GridView gridView2 = (GridView) gridView1.GetDetailView(gridView1.FocusedRowHandle, 0);

unfortunately it got bug which i unable to solve. it work provided i don't click other master section cell. An error object message will pop up; once i click other cell at master section, and i go back to click on my previous detail cell.

enter image description here

2

2 Answers

0
votes

As it explained in the Detail Pattern and Clone Views article:

detail Views shown at runtime are all Clones of an abstract detail View, called a Detail Pattern View

gridView2 in your case is the Pattern view for all details views being created when the user expands a master row. Pattern views act as the repository of the view settings and do not take part in real processes.

To work the the particular view, you need to obtain the corresponding Clone of the Pattern view. There are a few approaches to obtain it.

  • If you know the master row handle and the relation index, you can obtain the detail view instance using the GetDetailView method of the master View.

  • You can use the GridControl.FocusedView property to reference a View that is currently focused in the GridControl. This can be a master View or a detail View, depending on where the user puts the focus.

  • When you handle a GridView event, as you did, the GridView instance that raised the event is passed as the sender parameter to the event handler. Thus, you can cast the sender to the GridView type and work with it.

0
votes

I solved it by the below googled code with little of modification to suit by program structure.

 GridView detailView = sender as GridView;
 GridView gv = (GridView)gridView1.GetDetailView(detailView.SourceRowHandle, 0);