Hello everyone, I have a button handler in WinForms, when I press a button, I get and CheckedListBox contents of the collection in CheckedListBox . The collection itself consists of two text fields, this is the name of the rubric and its URL. Further on the form I choose the positions I need. And when I press the second button, I want to form a parameterized List of the selected items. But I only form the list with those Items that have been selected, but these are only names, but I don’t know how to get the URLs of the selected positions, here’s the code.
Here is the handler of the first button that gets the list of sections.
private void button1_Click(object sender, EventArgs e) { string urlsRubr = "https://www.rabota66.ru/resume"; // тут получаю саму коллекцию все ок. var listt= pars.GetRubrik(urlsRubr).ToArray(); // заполняю сам список на форме. Вывожу собственно имена рубрик. // У x есть еще один параметр это x.UrlRubrik тут храниться сами урлы. checkedListBox1.Items.AddRange(listt.Select(x => x.NameRubrik).ToArray()); } Here is the handler of the second button, when clicked, the selected positions are stored in the same parameterized List . But the problem is that I will add only the names of the headings, and how can I also hook the urls themselves. Can I somehow get the name and invisible url on the form, so that together we can put it all into the collection with the selected items?
private void button2_Click(object sender, EventArgs e) { List<Rubriks> Chek=new List<Rubriks>(); foreach (var item in checkedListBox1.CheckedItems) { Chek.Add((Rubriks) item); } } 