The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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);
}
ADAdministrator 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
ADAdministrator 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.