Hi all,I have an UltraGrid bound to a view. It is basically a mapping between a string and an int value so I have two visible columns.For the int column I added a ValueList which I the attached to the column.
If I run the project the ValueList is shown, I can type (autocomplete) so it seems quite fine.
Unfortunately if I type something that does not exist in the ValueList I receive a FormatException.
I have set the Style of the column to DropDownValidate, assuming that this would fix it, but it didn't.
I know that I can set it to DropDownList, but I want the users to type more than one character for the autocompletion.
I also tried the BeforeExitEditMode event, but as expected the typing of the character itself causes the ValueList to fail (because the value does not exist).
How can I work around this? I want the user to type more than one character for the autocompletion and if he/she entered something invalid prompt the user with some options and not allow the cell to be left until this is done.
Any help is kindly appreciated,
best regards
Andy
Hi Mike,
Thanks a lot for your answer. It totally makes sense ;)
I thought that there would be a possibility to intercept the value entered and avoid the error beeing thrown. The sad thing is that it gets thrown while typing.If, for example, the character y is typed and the list does not contain any string beginning with y the error is thrown immediately. I could not find any event that is raised before that happens so I am unable to reset the text or do anything alike.
I figured out that the DropDownList style also allows for more than one character to be typed if you type fast enough, so this will work for me.
Thanks again for your support and have a nice weekend,cheersAndy
Hi Andy,
If I understand you correctly, then the column in your grid is of type int (Int32). And you have a ValueList on the column which is converting those integers into some user-friendly display text.
In such a case, it is not possible for the user to enter a string into the column that does not exist on the list. When you type in something that does not exist on the list, the Value of the cell cannot be translated from the string into an integer, so the value of the cell becomes the string you typed. But since the field is an int, it cannot store a string, and so you will get an exception.