There are some columns in the ultragrid(in winform), one column is POQty and the other column is RecQty, and they must be positive number,Now after input the value in the RecQty column,if the value of RecQty is greater than the value of POQty,then show a warning message .
By the way, is there a property of ultragrid to set the column only accept postive number?
Many thanks
I guess it depends on what your wingrid’s data source is to go about this. Assuming you were using an ADO data table as the wingrid’s datasource, I would create a validation method that hooks into the data table’s row changed event to check and see if the RecQty column value is greater than the POQty column value and then if necessary use the data row’s Set Column Error method with the error message. But in order for the gird to display the message you have to make sure to set the wingrid’s SupportDataErrorInfo property to CellsOnly or RowsAndCells else the grid will ignore the error information.
If you are trying to do something simple then you can just use the grid’s AfterRowUpdate event and then examine the two columns and respond appropriately.
You can prevent the user from entering negative numbers using the wingrid designer going to the appropriate band and columns section. Each column has a MaskInput property that you can set. The mask will for the user to enter information in the format you specify. Alternatively, you can use something like the Numeric Editor control and set it's mask to not allow negatives and then set the wingrid column's EditorControl property to that control and the cell will effectively host the specified control as the editor.
How does that sound?
Depending on what kind of "warning message" you want to show, you might want to use InitializeRow, instead of AfterCellUpdate. AfterCellUpdate is good if you want to show a MessageBox. If you want to warn the user using a color or an image in the cell, then InitializeRow would be better.
Also, there's a property on the column called Style that you can use to prevent negative numbers for certain numeric types. You can also use the mask, but Style is simpler, as it's an enum.
Still another option would be to use the UltraWinValidation component.