I already make the thread as "solved" but i actually have 1 more question, about this thread: http://www.daniweb.com/software-development/csharp/threads/359558/1534169#post1534169

How can i copy the subitems of the checked items?

Recommended Answers

All 4 Replies

It this case it would be better to create some collection of the items. Lets say we use a generic list<T>, which will hold all the checked items, and those will be shown in listView2. So all you havw to do, is to copy all checked item to this list, and populate listView2 with all these items.

List<string> list;

        private void button1_Click(object sender, EventArgs e)
        {
            list = new List();
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].Checked)
                {
                     list.Add(listView1.Items[i].SubItems[1].Text); 
                }
            }

            //clearing listView2
            listView2.Items.Clear();
            //populating listView2 from the list:
            foreach(string item in list)
                  listView2.Text = item;
        }

it's actually a problem with it:
list = new List();

List can only be with those <>
and the type is string but it's already written above..
so what should i do with it?

Yes, sorry, I wrote the code by heart, so errors can happen.
Repair the code to:

List<string> list;
 
private void button1_Click(object sender, EventArgs e)
{
        list = new List<string>();
   //code
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.