main
1using System.Windows.Forms;
2using gorilla.commons.utility;
3
4namespace MoMoney.Presentation.Winforms.Databinding
5{
6 public class ComboBoxPropertyBinding<TypeToBindTo, PropertyType> : IPropertyBinding<PropertyType>
7 {
8 readonly IPropertyBinder<TypeToBindTo, PropertyType> binder;
9
10 public ComboBoxPropertyBinding(ComboBox control, IPropertyBinder<TypeToBindTo, PropertyType> binder)
11 {
12 this.binder = binder;
13 control.SelectedItem = binder.current_value();
14 control.SelectedIndexChanged +=
15 delegate
16 {
17 binder.change_value_of_property_to(control.SelectedItem.converted_to<PropertyType>());
18 };
19 }
20
21 public PropertyType current_value()
22 {
23 return binder.current_value();
24 }
25 }
26}