Current filter:
                                You should refresh the page.
                                Support Center
                                  • I have a master-detail grid. When I try to use the FocusedRowHandle property of the detail view, it always returns -999999. The FocusedRowHandle property of the master grid view returns the correct result. Here is my code:

                                    int row = gridView2.FocusedRowHandle; // gridView2 is a detail grid view Console.WriteLine(row); // row is always -999999

                                1 Solution

                                Creation Date Rating Importance Sort by

                                A common mistake when performing data specific operations in master-detail mode on detail views (deleting and obtaining records, collapsing/expanding groups and master rows, etc) is using pattern views which are created at design time and used as sublevels of the GridControl. Pattern views don't contain any data and they are never displayed on screen. Pattern views only serve as templates, i.e. they provide layout settings for representing the data displayed by real detail views (clones). You can get detailed information on pattern and clone views in the XtraGrid help file.

                                For example, consider the following scenario:

                                Your master GridView has two details expanded. Both these detail views are created using the DetailGridView pattern view, right?

                                Then, if you call the DetailGridView .SetRowCellValue(rowHandle, fieldName, value), it is not clear in which view you expect GridView will make changes: in the first one or in the second one? Both these views can have the same row handles and columns.

                                If you wish to make changes only in the focused view, in this case use methods of this view. For example, GridControl.FocusedView.SetRowCellValue(rowHandle, fieldName, value)

                                There are several ways to access the real grid view with which an end user interacts at runtime:

                                   GridControl.MainView - returns the top most view in a grid
                                   GridControl.FocusedView - returns the focused view
                                   the sender parameter of view specific events
                                   GridView.GetDetailView - returns a detail view for a specific master row.

                                After the required view is obtained, you can get the currently focused row via the view's FocusedRowHandle property or use any other property or method of the detail view.

                                using DevExpress.XtraGrid.Views.Base; // Obtain the focused row of the currently focused view int detailRowHandle = ((ColumnView)gridControl1.FocusedView).FocusedRowHandle; // Obtain the focused row of a specific detail view, if expanded // gridView1 corresponds to GridControl.MainView int masterRowHandle = 0; int relationIndex = 0; if(gridView1.GetMasterRowExpandedEx(masterRowHandle, relationIndex)) { ColumnView detailView = (ColumnView)gridView1.GetDetailView(masterRowHandle, relationIndex); int detailRowHandle = detailView.FocusedRowHandle; }
                                Imports DevExpress.XtraGrid.Views.Base ' Obtain the focused row of the currently focused view Dim detailRowHandle As Integer = (CType(gridControl1.FocusedView, ColumnView)).FocusedRowHandle ' Obtain the focused row of a specific detail view, if expanded ' gridView1 corresponds to GridControl.MainView Dim masterRowHandle As Integer = 0 Dim relationIndex As Integer = 0 If gridView1.GetMasterRowExpandedEx(masterRowHandle, relationIndex) Then Dim detailView As ColumnView = CType(gridView1.GetDetailView(masterRowHandle, relationIndex), ColumnView) Dim detailRowHandle As Integer = detailView.FocusedRowHandle End If

                                See Also:
                                Pattern and Clone Views

                                • Mustafa_Korkmaz 07.13.2013

                                  this post was very useful for me thanx a lot

                                • Hi,

                                  We are glad to hear that. Please feel free to contact us in case of any difficulties.

                                • ari laksono 12.05.2015

                                  Thats it's Good & it's Work For me
                                  thanks al lot...

                                • ari laksono 12.05.2015

                                  _gridViewTD1.ExpandMasterRow(_gridViewTD1.FocusedRowHandle, 0);
                                             int masterRowHandle = _gridViewTD1.FocusedRowHandle;
                                             int relationIndex = 0;
                                             if (_gridViewTD1.GetMasterRowExpandedEx(masterRowHandle, relationIndex))              
                                                 ColumnView view1D = (ColumnView)_gridViewTD1.GetDetailView(masterRowHandle, relationIndex);                
                                                 Decimal TotluasBlok1 = 0;
                                                 Decimal TotALokasiBiaya1 = 0;

                                                 int iRowD1 = 0;
                                                 int iCount1 = 0;
                                                 foreach (DataRow row1 in dvAsm3TBM.Table.Rows) //filterDv_GLokup1.Table.Rows)
                                                     Decimal luasBlok1 = _Syb3InitPub1._mySyb3Db2.Syb3IsNullDec(row1["LUASBLOK"]);
                                                     Int16 glm3Code = _Syb3InitPub1._mySyb3Db2.Syb3IsNullInt16(row1["GLM3CODE"]);

                                                     Decimal ALokasiBiaya1 = luasBlok1 / LuasTbm1 * totBiaya2;

                                                     iRowD1 = view1D.FocusedRowHandle;
                                                     view1D.SetRowCellValue(iRowD1, "NOURUT", iCount1);
                                                     view1D.SetRowCellValue(iRowD1, "GLM2CODE", glm2CodeRDB);
                                                     view1D.SetRowCellValue(iRowD1, "GLM3CODE", glm3Code);
                                                     view1D.SetRowCellValue(iRowD1, "FCM2CODE", row1["FCM2CODE"]);
                                                     view1D.SetRowCellValue(iRowD1, "KETDETAIL", "Alokasi Biaya Overhead " + row1["CODE"]);
                                                     view1D.SetRowCellValue(iRowD1, "LUAS", luasBlok1);
                                                     view1D.SetRowCellValue(iRowD1, "MUTDB", ALokasiBiaya1);


                                                     TotluasBlok1 = TotluasBlok1 + luasBlok1;
                                                     TotALokasiBiaya1 = TotALokasiBiaya1 + ALokasiBiaya1;


                                • Hello,
                                  Would you please clarify whether you need any help with the code posted above? 

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners