Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • 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:

                                    [C#]
                                    int row = gridView2.FocusedRowHandle; // gridView2 is a detail grid view Console.WriteLine(row); // row is always -999999
                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                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.

                                [C#]
                                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; }
                                [VB.NET]
                                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
                                A273
                                A527

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com 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, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

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