main
1using ComponentFactory.Krypton.Toolkit;
2using MoMoney.Presentation.Winforms.Helpers;
3
4namespace MoMoney.Presentation.Winforms.Krypton
5{
6 public class KryptonComboBoxListControl<TItemToStore> : IListControl<TItemToStore>
7 {
8 readonly KryptonComboBox combo_box;
9
10 public KryptonComboBoxListControl(KryptonComboBox combo_box)
11 {
12 this.combo_box = combo_box;
13 }
14
15 public TItemToStore get_selected_item()
16 {
17 return (TItemToStore) combo_box.SelectedItem;
18 }
19
20 public void add_item(TItemToStore item)
21 {
22 combo_box.Items.Add(item);
23 combo_box.SelectedIndex = 0;
24 }
25
26 public void set_selected_item(TItemToStore item)
27 {
28 if (!Equals(item, default(TItemToStore)))
29 if (combo_box.Items.Contains(item)) combo_box.SelectedItem = item;
30 }
31 }
32}