Hi,
I have a win grid with the new row template at the top and combo box outside the panel of the grid. When i click on the new row template, start editing it and leave before filling all the fields (i.e. i click on some other field outside grid panel), the new row gets added to the grid which is undesirable as few of the mandatory fields are left blank. The new row needs to be validated before getting added to the grid.
I added this event BeforeRowUpdate and doing the following to validate the fields.
Though i am able to validate this way, but the partially filled new row is getting lost after this instead of being retained.
void gridOwner_BeforeRowUpdate(object sender, CancelableRowEventArgse)
{
if (e.Row.IsAddRow)
foreach ( UltraGridCell item in e.Row.Cells)
if (item.Value.ToString().Trim().Length <= 0 && !item.Column.Hidden)
MessageBox.Show("Please select a value for " + item.Column.Header.Caption.ToString());
e.Cancel = true;
break;
}
There fore, i am looking for some way to validate the new row before adding to the grid and even if the validation fails, the new row should not be discarded rather it should be held in the template where it is entered.
Thanks in advance,
Parthiban Sekar
Hello,
I have modify my sample based on your requirements, please run the sample and let me know if this is what you are looking for.
Thank you for using Infragistics Components.
Hristo, Could you help me out :)
Thanks
Hristo,
I really appreciate your efforts to help me.
To replicate what i am facing, please do the following changes.
1. Add a combo below the grid ( or wherever but away from the grid panel )
2. Now run the app, start editing the new row template but dont enter all fields , now click on the drop down (outside grid panel).
For me the validation did not happen and row got added to the grid.
The modified sln is attached.
Regards,
I have modify my sample to work with Visual Studio 2008, now you should be able to run and test the sample.
Please let me know if you have any further questions.
Not able to open the attached sample. I have VS2008.
Btw, i have implemented everything you suggested. But the event BeforeRowDeactivate is not getting triggered after the edit
and
grid.ActiveRow.IsAddRow is false when i edit the new row (The event gets triggered when i click on new row template)