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
1878
Exception when item is not in list on UltraComboEditor
posted

Hi there,

in our application we have several combos for displaying things like payment method, tax class, credit card type etc. for an Order. In the Order those items are stored with their id (PaymentMethodId, TaxClassId, CreditCardTypeId) as integer values. Some of those combos are UltraCombo, other UltraComboEditor classes. I've set their DropDownStyle to DropDown, the AutoCompleteMode to SuggestAppend. The list of items, the combos are displaying, are fetched from a list of our business objects using MS BindingSource, I've set the DataBindings properties Value, DisplayMember and ValueMember appropriately and that works at it should be.

To prevent entering values that are not in the list of items I've attached an event handler to the ItemNotInList event. In that handler I proceed as you suggested in one of your examples which also works fine.

Now with one of the several UltraComboEditor objects used I've a small problem. I've also subscribed for BindingComplete event on the Order object to check if an error during binding occurs. In this one combo as soon as I enter one single character which never could lead to a valid item of the list the BindingComplete event is fired with a System.FormatException saying that the input string was not in correct format. I can of course suppress this exception but I would like to understand how this could be. From my understanding data is only written back to the Order business object when the UltraComboEditor looses focus which is not the case. I also don't understand why this event gets fired before the ItemIsNotInList event so that I can appropriately react on that. I even registered a Click event on that combo to check before if the item is in the list but also that is not called before the BindingComplete event.

It's strange that I experience this problem just with one UltraComboEditor while other's are working fine although they are all working the same way on the same Order Business Object? When I enter an illegal value in the other combo boxes the event handler for ItemNotInList event gets called and I can react on that appropriately.

Any ideas?

Kind regards,
Wolfgang

Parents
  • 469350
    Offline posted

    Hi Wolfgang,

    qbupoew said:
    From my understanding data is only written back to the Order business object when the UltraComboEditor looses focus which is not the case.

    I'm not entirely sure that this is a correct assumption. I'm pretty sure there are several options for this. But my guess is that if you are binding the Value property of the control, then the underlying data object will be updated any time the control fires the ValueChanged event. That's how the BindingManager works - it looks for an event with the same name as the property and listens to it.

    Assuming the combo had a valid value in it and was not null, then typing an invalid character could change the Value to null, which would fire ValueChanged which might trigger an exception.

    I could be wrong about all of this, of course. It's very tough to say with so little information. It might help if you could post the call stack of the exception. You seem to be under the impression that the exception is coming from the data source, but that exception message looks like something that is coming from the combo to me, and in fact, it looks like a FirstChanceException that you would not normally see unless you have set the IDE to break on all run-time exceptions - even ones that are already handled.

Reply Children
No Data