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.
Unfortunately, activation email could not send to your email. Please try again.

Prevent navigation until new row entry complete

Thread ID:

Created:

Updated:

Platform:

Replies:

25596 Mar 1,2005 10:15 PM Mar 2,2005 04:39 AM Windows Forms 1
loading
Tags: GridControl
Richard
Asked On March 1, 2005 10:15 PM

Hi, How can I prevent the user from navigating to a different record, from an "add new record row", until they have entered all the required fields.

Administrator [Syncfusion]
Replied On March 2, 2005 04:39 AM

Try handling the RowLeave event and cancel it if you are editing the AddNew row and your required fields are not occuppied.
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
	if(this.gridDataBoundGrid1.Binder.IsAddNew && !IsRowOk(e.RowIndex))
	{
		e.Cancel = true;
	}
}

private bool IsRowOk(int row)
{
	bool ret = true;
	for(int i = 1; i < this.gridDataBoundGrid1.Model.ColCount; i++)
	{
		string s = this.gridDataBoundGrid1[row, i].Text;
		if( s == null || s.Length == 0)
		{
			ret = false;
			break;
		}
	}
	return ret;
}

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.

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.

;