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

Validating a whole row in Syncfusion 4.1.0.50

Greetings and well met!
What''s the best approach to validate a whole row in one task, when the user leaves the row. The main goal is to recreate the functionality of an M$ Access Frontend Database

Thanks in Advance!

11 Replies

AD Administrator Syncfusion Team August 17, 2006 01:23 PM UTC

Hi Christian,

If you want to validate the whole row, you need to handle the RowLeave event in a grid. Please refer the attached sample, which implements the RowLeave event.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/rowvalidation_56bf4b3b.zip

Please refer the KB for more details.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=340

Thanks for choosing Syncfusion Products
Regards,
Haneef


CF Christian Fleischhacker August 21, 2006 08:09 AM UTC

Hi Haneef!

Thanks for your quick reply, i really apreciate it. The row-leave event works quite fine right now exept the fact that this event is raised after i created/filled a grid and enter a row/any row for the first time (via mouse); Is this a intendend behavior, or did I something wrong?


AD Administrator Syncfusion Team August 21, 2006 08:50 AM UTC

Hi Christian,

Yes. This is a default behavior of the grid. The RowLeave event occurs after the current cell''s changes have been saved and before it is deactivated and the changes in the current row are saved to the underlying data table.

Let me know if this helps.
Best Regards,
Haneef


CF Christian Fleischhacker August 21, 2006 09:30 AM UTC

Hi Haneef!

Yes this helps me a little bit, but right now i''m occupied looking for a good way to determine wether a grid is "new" i.e. a new row or if the row is already in place :-)
any good ideas or hints


AD Administrator Syncfusion Team August 21, 2006 10:15 AM UTC

Hi Christian,

Use this code snippet to find the grid is empty or not.

if( this.grid.DataSource == null && this.grid.GridBoundColumns.Count == 0 )
{
Console.WriteLine("Grid is Empty Grid..." );
}
else
{
Console.WriteLine("Grid is not a Empty Grid...");
}

Let me know if you are looking something different.
Regards,
Haneef


CF Christian Fleischhacker August 21, 2006 11:01 AM UTC

Hi Haneef!

No i was looking for descent way to determine wether this row/cell is a complete new one or a old one just being edited (I know i could see if the cell already contains a value, but if the user deletes the value inside and then leaves the cell i''m screwed again;)

Thanks anyway for your effort


AD Administrator Syncfusion Team August 21, 2006 12:55 PM UTC

Hi Christian,

If you want to find the AddNewRow in RowEnter/ RowLeave Event, you need to check the property e.IsAddNew. Below code snippet

private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
if(e.IsAddNew)
{
MessageBox.Show("AddNewRow");
}
}

Let us know if this is not the information you needed.
Thanks
Haneef


AD Administrator Syncfusion Team August 21, 2006 02:49 PM UTC

Hi Haneef!

I think this is the stuff i''m looking for; This property tells me wether a new row has been added or not, right?

And this property is set to false, when i refresh the whole grid via methods like (GridDataBoundGrid.EndUpdate or .currentCell.Refresh)?


CF Christian Fleischhacker August 25, 2006 08:10 AM UTC

hi Haneef!

I need your help again; is there a property or function like e.IsAddNew (where e Syncfusion.Windows.Forms.Grid.GridRowEventArgs) availabe "outside" the row_leave event? the reason why i ask is that i have a windows button that calls the gdbg.refresh sub and i would like to check first if the user is in cellEdit mode AND has created a new cell, because then he shouldn''t be able to refresh the grid


AD Administrator Syncfusion Team August 25, 2006 09:27 AM UTC

Hi Christian,

By Defalut, The CauseValidation property of any control is TRUE. It indicates whether the control can cause validation to be performed on any controls that require validation when it receives the focus.

In such scenario the grid''s Validate method will get called which then will commit changes in the AddNew row to the underlying datasource. So you need to set the CauseValidation property of the Button control ( IsAddNewRecordButton ) to FALSE. You can use the Binder.IsAddNew property to find the add new record and use Binder.IsAppendRow property ot find newly appended row. Below is a code snippet

//Form Load
IsAddNewRecordButton.CausesValidation = false;

private void IsAddNewRecordButton_Click(object sender, System.EventArgs e)
{
if( this.gridDataBoundGrid1.Binder.IsAddNew || this.gridDataBoundGrid1.Binder.IsAppendRow )
{
Console.WriteLine("CurrentCell is in AddNewRecord");
}
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/CheckAddNewRecord_20799147.zip

Let me know if this helps.
Best Regards,
Haneef


CF Christian Fleischhacker August 28, 2006 08:36 AM UTC

Hi Haneef!

Thanks for you reply i will check this out and write it down for the future ;-). I think this will help me a lot, thanks again

Loader.
Live Chat Icon For mobile
Up arrow icon