Hi,
I would like to use an ultravalidator to check if the value selected is in my list. I have the following code :
this.ultraComboTiers.DataSource = this.bindingSourceATiers;
bindingSourceATiers.DataSource = GetTiers();
and
this.ultraValidator1.GetValidationSettings(this.ultraComboTiers).Condition = new Infragistics.Win.ContainedInListCondition(bindingSourceATiers, Infragistics.Win.ListItemMatchMode.DataValue);
But it does not work. How can I perform this ?
Thx
You were not very specific about the observed behavior so it is difficult to speculate, but one thing I noticed is that you are using a ListItemMatchMode of 'DataValue', which means the underlying value of the item is compared (as opposed to the display text). This means that if the values typed by the user are the thing being validated (as would usually be the case when you leave the ValidationSettings.ValidationPropertyName at its default, which means the Text property is used), the condition will never be met. If you have already determined that this is not the cause of the problem please be more specific about the observed behavior and we can try to help.
Hello,Hmm I will try to be more specific with the following code ://I have an UltraComboEditor binded to a bindingsourcethis.cityBindingSource.DataSource = typeof(City);this.ultraComboCities.DataSource = this.cityBindingSource;//then the bindingsource is plugged to my list of cities :BindingList<City> _allCities = new BindingList<City>();this.cityBindingSource.DataSource = _allCities;//I want to check if the value selected on the combobox is one of _allCities (and it should) by a ultravalidator :this.ultraValidator1.GetValidationSettings(this.ultraComboCities).Condition = new Infragistics.Win.ContainedInListCondition(this.cityBindingSource, Infragistics.Win.ListItemMatchMode.DataValue);this.ultraValidator1.GetValidationSettings(this.ultraComboCities).EmptyValueCriteria = Infragistics.Win.Misc.EmptyValueCriteria.Null;this.ultraValidator1.GetValidationSettings(this.ultraComboCities).IsRequired = true;this.ultraValidator1.GetValidationSettings(this.ultraComboCities).NotificationSettings.Action = Infragistics.Win.Misc.NotificationAction.BalloonTip;this.ultraValidator1.GetValidationSettings(this.ultraComboCities).NotificationSettings.Text = "Invalid value.";this.ultraValidator1.GetValidationSettings(this.ultraComboCities).RetainFocusOnError = true;However even when I select one of the row, I got the ballontip.I also tried with this :((ContainedInListCondition)ultraValidator1.GetValidationSettings(this.ultraComboCities).Condition).List = _allCities;And got the same issue.In fact I don't really know which IList I should pass to the condition to do what I want.Some hints ?
I think what is going on is this: When you assign something other than an Infragistics ValueListItems collection to the List property of the ContainedInListCondition class, the IList's Contains method is used to determine whether the value is contained within the list. In this scenario, that will never work since the list contains instances of a type other than the value being compared. You should probably just assign the ultraComboCities.Items collection to the List property, so that it is dealing with ValueListItems instead.
I works perfectly now. Thanks.
Renaud