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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Question for databoundgrid.

Thread ID:

Created:

Updated:

Platform:

Replies:

37114 Nov 16,2005 04:56 AM UTC Nov 16,2005 08:56 PM UTC WinForms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 16, 2005 04:56 AM UTC

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

Administrator [Syncfusion]
Replied On 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;
}

Administrator [Syncfusion]
Replied On 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 >

Administrator [Syncfusion]
Replied On 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???)

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;