foreach (var item in documents)
{
lstMyList.Items.Add(item.Name + "\t\t" + item.Value + "\t\t");
}
It displays the list with the values side by side. When I select a value from the list, I want to capture just the item.Name value. How can I do that?
ASKER
ASKER
lstMyList.View = System.Windows.Forms.View.Details;
lstMyList.FullRowSelect = true;
lstMyList.Girdlines = true;
lstMyList.Columns.Add("Name", 200);
lstMyList.Columns.Add("Value", 200);
foreach (var item in documents)
{
lstMyList.Items.Clear();
ListViewItem lvi = new ListViewItem(item.Name);
lvi.SubItem.Add(item.Value);
lstMyList.Items.Add(lvi);
}
ASKER
ListViewItem lvi = new ListViewItem(item.Name.ToString());
lvi.SubItem.Add(item.Value.ToString());
I get the last record in the list of values in the list, but not any of the others. I've got it wrong in the foreach loop, I think?
ASKER
C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).
TRUSTED BY
You can always put a separator between item.Name and item.Value and then split from that OR use Combobox that can support Display and Value parts independently.
Regards,
Chinmay.