ErrorProvider on Combobox

ErrorProvider on Combobox

Old forum URL: forums.lhotka.net/forums/t/5539.aspx


k2so posted on Monday, October 06, 2008

Hi,

Using CSLA 3.5 C#.

I have a ReadOnlyList "CountryList" object binded to a ComboBox in the UI.
ie. comboBox.DataSource = CountryList.GetList();

The value on selected is assigned to a "Country" property in a BO "businessObject", which had a StringRequired validation rule defined for the Country property.

How could I set the ErrorProvider to signal in the UI whenever the businessObject's country is not selected  (violating the validation?) ??

rkelley replied on Monday, October 06, 2008

Typically what I do is have a bindingsource that binds to your CountryList.GetList(); and then bind your combo box to that datasource.

Then I make sure that the databinding of the combo box is bound to the correct property on my BO and that the error provider is bound to the bindingsource of the BO. This usually makes it work for me.

Also, make sure you are calling ValidationRules.CheckRules() during the create/update/etc methods when needed.

k2so replied on Monday, October 06, 2008

I see now.

I've been using the on select change event to capture the value of the property instead of setting a binding.

Thanks.

Copyright (c) Marimer LLC