We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Inserting

Hi there, I am new to the data grid control and i used the edit option of the grid in edit mode through the IDE designer to add my column and headers. When i press add row (or by code) the header moves one line down and the new line is at index 0 of the grid. How can i get the normal behaviour , the header line doesn''t move and the new line is appended at the bottom ?

4 Replies

AD Administrator Syncfusion Team June 15, 2006 09:33 AM UTC

Hi OL, Try this code to add a row at the bottom of the last row in a grid. Here is a code snippet. this.gridControl1.RowCount = this.gridControl1.RowCount + 1 ; this.gridControl1.Data.RowCount = this.gridControl1.Data.RowCount + 1; Let me know if this helps. Best Regards, Haneef


OL Omry Levy June 15, 2006 12:31 PM UTC

Yes it worked Thanks But why is the default behaviour opposed to natural grid behaviour when adding a new row the header should stay at the top and the rows should append. Is there a style in the grid to achive this ? How can i change the cells content of the new row ?


OL Omry Levy June 15, 2006 01:37 PM UTC

How do i change the new row cells content by code , i know that they can have default values from the designer but i want to set them by code ? Thanks, 0L


AD Administrator Syncfusion Team June 16, 2006 09:22 AM UTC

Hi OL, You need to use the EndUpdateRequest event to sets the default values to the newly inserted row in a grid. Please refer to the sample for more details. bool IsPopulateValues = true; private void gridControl1_EndUpdateRequest(object sender, Syncfusion.Windows.Forms.Grid.GridEndUpdateRequestEventArgs e) { int NewRowCount = this.gridControl1.RowCount; if(IsPopulateValues && OldRowCount != -1 && OldRowCount != NewRowCount ) { IsPopulateValues = false; OldRowCount = NewRowCount; this.gridControl1.PopulateValues(GridRangeInfo.Cells(NewRowCount,1,NewRowCount, this.gridControl1.ColCount ) ,dt); this.gridControl1.RefreshRange( GridRangeInfo.Row(NewRowCount )); IsPopulateValues = true; } } You can add the rows to the anyposition of grid by using the Rows.InsertRange() method. this.gridControl1.Rows.InsertRange(5,1 ); // this code inserts a single row at the fifth position Here is a sample. http://www.syncfusion.com/Support/user/uploads/AddNewRowGC_4e9ee127.zip Let me know if this helps. Best Regards, Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon