using Northwind.TransferObjects.Presentation; using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace Northwind.UI.Controls { public class WinLookupList : ILookupList { public event EventHandler SelectedIndexChanged; private ListView underlyingList; public WinLookupList(ListView underlyingList) { this.underlyingList = underlyingList; this.underlyingList.SelectedIndexChanged += new EventHandler(underlyingList_SelectedIndexChanged); } void underlyingList_SelectedIndexChanged(object sender, EventArgs e) { if (SelectedIndexChanged != null) { SelectedIndexChanged(sender, e); } } public void Add(ILookupTO to) { ListViewItem lvi = underlyingList.Items.Add(to.Value, to.Value); lvi.SubItems.Add(to.Text); } public void Clear() { underlyingList.Items.Clear(); } public ILookupTO SelectedItem { get { if (underlyingList.SelectedItems.Count > 0) { ListViewItem lvi = underlyingList.SelectedItems[0]; SimpleLookupTO item = new SimpleLookupTO(lvi.Text, lvi.SubItems[0].Text); return item; } else { return null; } } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)