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
240
Ultra Combo - ItemNotInList event
posted

Been using Infragistics for over 1 year now.  We built a framework around the Winforms controls.  We have Comboboxes that need to detect if the value entered exists in the list the box is bound to and prompt if the value is a new value.

Everything has been working great, up until a "fix" was made to the combobox so that if the value entered is not found in the column defined as the display column, the value column is searched.  If the value entered is found in the value column, the combobox now points to that row of the list.

It has been suggested to use the ItemNotInList event to trap for this situation.  GREAT!  However, putting code in this event works fine, except that you can not put any kind of prompt in this method.  Once the prompt is hit, the displayed value changes to the row that contains that value in the id column.  We need to figure out how to trap for values not found, without changing the displayed value.

Thanks for any help.

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    I tested this out and I don't seem to be getting the same results you are describing.

    To test this out, I put an UltraComboEditor on a form with a button. The button does nothing, it's just there so I can take focus away from the combo.

    I populated my combo like so:


            private void Form1_Load(object sender, EventArgs e)
            {
                this.ultraComboEditor1.Items.Add(1, "A");
                this.ultraComboEditor1.Items.Add(2, "B");
                this.ultraComboEditor1.Items.Add(3, "C");
            }

    Now, I run the application and type in a "1" into the combo and click on the button.

    The combo shows an "A" and the ItemNotInList event does not fire.

     

    So there are two questions:

    1) Why is the combo showing an "A"?

    The reason for this is because when you type an item into the combo that is not on the list, it has to do something with the text you entered. Normally, it would take what you typed in, find the matching display text and the Value property of the combo would return the matching value on the list. But in the case where there is no matching item no the list, the Text and the Value of the combo both return the same thing - the text you entered.

    So when you enter a "1" and there is no item on the list with a DisplayText of "1", the Value and Text of the control get set to "1".

    Now... since there is an item on the list whose DataValue is 1, the control translates this into a display text of "A".

    The fix you mentioned was for a bug where when the text was not found on the list, the Value of the control was returning null. That was a serious bug that would prevent users from entering anything that was not on the list because when they did so, the Value would be null and then the Text would be cleared out, because there is no null item on the list.You would essentially lose what you typed.

    So all of this is as it must be and I don't see any way around it.

    2) Why isn't ItemNotInList firing?

    This is where I see a problem. When you type a "1" and there's no matching item on the list with a DisplayText of "1", the ItemNotInList event shoudl fire.

    What must be happening is that the value of the control has already been set to "1" and the "1" has been translated into an "A" before we determine whether or not to fire the event. This seems like it may be a bug and I'm going to forward this post over to Infragistics Developer Support so that this can be checked out.

     

     

Children