Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I wish to add new rows to a grouped grid, but the New Item Row is not displayed in this case. How can I do this?

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                You can add a button onto a toolbar for adding new rows. The button's Click event handler should call the procedure listed below. Please pay attention to the code, which initializes the new row's columns with the values of the current groups. It is necessary to make the new row appear in the desired group.
                                  

                                [VB.NET]
                                Public Sub AddRow(ByVal View As DevExpress.XtraGrid.Views.Grid.GridView) Dim currentRow As Integer currentRow = View.FocusedRowHandle If currentRow < 0 Then currentRow = View.GetDataRowHandleByGroupRowHandle(currentRow) End If View.AddNewRow() If View.GroupedColumns.Count = 0 Then Exit Sub ' Initialize group values Dim groupColumn As DevExpress.XtraGrid.Columns.GridColumn For Each groupColumn In View.GroupedColumns Dim value As Object = View.GetRowCellValue(currentRow, groupColumn) View.SetRowCellValue(View.FocusedRowHandle, groupColumn, value) Next View.UpdateCurrentRow() View.MakeRowVisible(View.FocusedRowHandle, True) View.ShowEditor() End Sub

                                [C#]
                                public void AddRow(DevExpress.XtraGrid.Views.Grid.GridView View) { int currentRow; currentRow = View.FocusedRowHandle; if (currentRow < 0) { currentRow = View.GetDataRowHandleByGroupRowHandle(currentRow); } View.AddNewRow(); if (View.GroupedColumns.Count == 0) return; // Initialize group values foreach (GridColumn groupColumn in View.GroupedColumns) { object value = View.GetRowCellValue(currentRow, groupColumn); View.SetRowCellValue(View.FocusedRowHandle, groupColumn, value); } View.UpdateCurrentRow(); View.MakeRowVisible(View.FocusedRowHandle, true); View.ShowEditor(); }
                                • Youssef Azarouali 2 10.10.2013

                                  Can you explain how to do it exactly? Where does the newrow appear? Or doe you have to build your own form with information for the row on it?

                                • Hi,

                                  I have extracted your inquiry to a separate Q461310 ticket. Please refer to it.

                                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