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

Question for databoundgrid.

Hi, I have a GDBG in which EnableAddNew is enabled. I want preventing user select last row (empty row). How can I do that? Thanks a lot. --Shuyang He

3 Replies

AD Administrator Syncfusion Team November 16, 2005 09:00 AM UTC

So, you want to see the AddNewRow, but you do not want your users to be able to move into it? If so, try handling grid.CurrentCellMoving and set e.Cancel = true if the target row is the last row in the grid.
private void gridDataBoundGrid1_CurrentCellMoving(object sender, GridCurrentCellMovingEventArgs e)
{
	if(e.RowIndex == this.gridDataBoundGrid1.Model.RowCount)
		e.Cancel = true;
}


AD Administrator Syncfusion Team November 16, 2005 08:47 PM UTC

Hi, Sorry, I did not specify the question clearly. I have a delete button to allow users to delete multiple selected rows. But if I have only one row (empty row) left and selected. When I tried to delete it, the grid throws exception. Is there any good solution for it? Here is my code to handle delete rows. Dim MyRanges As GridRangeInfoList = aGrid.Selections.GetSelectedRows(True, False) For index As Integer = MyRanges.Count - 1 To 0 Step -1 Dim rowidx As Integer = MyRanges.Item(index).Top aGrid.Binder.RemoveRecords(rowidx - 1, rowidx - 1) Next >Hi, > I have a GDBG in which EnableAddNew is enabled. I want preventing user select last row (empty row). How can I do that? > >Thanks a lot. > >--Shuyang He >


AD Administrator Syncfusion Team November 16, 2005 08:56 PM UTC

Try checking if rowidx == this.grid.Model.RowCount. If it is equal, then do not delete it. (or, you could set grid.EnableAddNew = false at that point to hide the AddNew row though I am not sure how you would then want your user to turn it back on???)

Loader.
Live Chat Icon For mobile
Up arrow icon