Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1965
WinGrid - Validating the new row before adding it to the grid using new row template
posted

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

Parents Reply Children