Store value from ListView items(column2) to List<string>


have winform, listview(2 columns), textbox, , 3 buttons(add, ok, cancel) in code have list, can store listview items. when click add button, value textbox added on listview , when click ok button, items listview added on list. need add items second column.

when click ok button, items first columns being added list..

can me on how add items second column list ?? thanks.

here's code:

public partial class lottrace_01 : form  {      public list<string> lotlist = new list<string>();        public int = 0;        public lottrace_01()      {          initializecomponent();         }        private void btnadd_click(object sender, eventargs e)      {             += 1;          listview1.items.add(i.tostring()).subitems.add(txt_add.text);        }        private void btnok_click(object sender, eventargs e)      {          for (int = 0; < listview1.items.count; i++)          {              if (lotlist.contains(listview1.items[i].text) == false)              {                  lotlist.add(listview1.items[i].text);              }          }          this.close();      }    }

with linq, try following:

lotlist = listview1.items.select(x => x.subitems[1].text).distinct().tolist();




Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'