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
543
WinGrid cell validation
posted
Hi,
in my application I use a WinGrid to collect informations about a set of properties. The grid has two columns, one for the name of the properties, and the other for the values. So, each row in the grid represents a single property. Depending on property type and attributes, the cell holding value has a particular style and editor (ColumnStyle.Double, ColumnStyle.Date, ColumnStyle.DropDown, ...).

I would like to set a max length for text-type properties, but unfortunately it seems to be a column-only attribute. So I have to make a little validation on my fields, but I can't find a pretty solution to the following questions:

- which is the best event I can use to trap all changes to my value fields? Now I'm using 'BeforeCellUpdate', but it doesn't allow me to force the cursor to remain in the not-validating cell. So I tried to use 'BeforeExitEditMode', but it doesn't fire on DropDown fields...

- how can I replace the value that doesn't validate (value too long, for example) with a correct value (the same value, trimmed, for example), in which event? I tried to set a new value to the cell in 'BeforeCellUpdate', but it raises an exception:
"Value property can not be assigned while BeforeCellUpdate event is in progress".

Please let me know if I'm missing something... :)

Thank you for your time,
Valentina