Manual Delete row from GridControl does not work

I have a GridControl which i populate manually. I have a button on the form the add a row at the end. I also have a button that tries to remove this last row. My problem is that the add row works, but the remove row does nothing. What gives? I am new to this grid and need some help. Also, Is there any documentation on the sequence of events? private void buttonAdd_Click(object sender, EventArgs e) { int rowIndex = this.gridControl.RowCount + 1; this.gridControl.Model.Rows.InsertRange(rowIndex, 1); } private void buttonDelete_Click(object sender, EventArgs e) { int rowIndex = this.gridControl.RowCount; this.gridControl.Model.Rows.RemoveRange(rowIndex, 1); }

2 Replies

AD Administrator Syncfusion Team June 19, 2006 03:34 PM UTC

Hi Jamesb, Try this code to remove the last row in a grid. Here is a code snippet. int rowIndex = this.gridControl1.RowCount; this.gridControl1.BeginUpdate(); this.gridControl1.RowCount -= 1; this.gridControl1.EndUpdate(true); Let me know if this helps. Best Regards, Haneef


AD Administrator Syncfusion Team June 19, 2006 03:38 PM UTC

Hi James, In the Rows.RemoveRange() the first row index and the last row index of the range that you want to delete should be passed as argument. Below is a code snippet to delete the last row. int rowIndex = this.gridControl1.RowCount; this.gridControl1.Model.Rows.RemoveRange(rowIndex-1, rowIndex-1); Regards, Calvin.

Loader.
Up arrow icon