main
1using System;
2using System.Windows.Forms;
3
4namespace MoMoney.Presentation.Winforms.Helpers
5{
6 public class TextControl<ItemToStore> : ITextControl<ItemToStore>
7 {
8 readonly TextBox textbox;
9 ItemToStore selected_item;
10
11 public TextControl(TextBox textbox)
12 {
13 this.textbox = textbox;
14 when_text_is_changed = () => { };
15 textbox.Leave += (sender, args) => when_text_is_changed();
16 }
17
18 public void set_selected_item(ItemToStore item)
19 {
20 textbox.Text = item.ToString();
21 selected_item = item;
22 }
23
24 public ItemToStore get_selected_item()
25 {
26 return selected_item;
27 }
28
29 public string text()
30 {
31 return textbox.Text;
32 }
33
34 public Action when_text_is_changed { get; set; }
35 }
36}