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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Prevent navigation until new row entry complete

Thread ID:

Created:

Updated:

Platform:

Replies:

25596 Mar 2,2005 03:15 AM UTC Mar 2,2005 09:39 AM UTC WinForms 1
loading
Tags: GridControl
Richard
Asked On March 2, 2005 03:15 AM UTC

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 09:39 AM UTC

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.

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

;