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
280
ItemNotInList Event - How to remove??
posted

I'm using VB.NET, and I have tried to remove the WinCombo ItemNotInList event using the VB.NET RemoveHandler statement. However, when I do that, my form validation fails when using ValidateChildren(). If I remove the RemoveHandler then the form passes validation just fine.

I tried using the EventHandlerDictionary method to remove the event, but couldn't get the right syntax. I kept getting a compile error from the method saying "expression does not return a value".

While typing this I was also testing: it looks like the issue is caused by the e.RetainFocus property of the ValidationErrorEventArgs class. If I leave the event hooked up, and set RetainFocus = False, validation passes. If I set it to True (the default) it causes validation to fail. Note that ValidateChildren() causes this event to fire. So it looks like the VB RemoveHandler DID remove the event, but the RetainFocus is left set to the default value of True which causes validation to fail.

As far as I know, there is NO way besides within the ItemNotInList event to set this property. Is that true?? My solution was to check some member flags, and if ok set RetainFocus=False. This seems like a hack.

Please advise. Thanks.

Parents Reply Children
No Data