Hey I have a question.. I have a list in one form that looks like this:

[column1] - [column2]

item1 - 0
item2 - 6
item3- 8
item4 - 5
item5 - 2

soo.. now I open a new form and I need to select what kind of items I want from column 2.
So I select from 2 to 7.

So I select (in theory) item2, item4 and item5 from my listview from another form.

Here's the code I have:

private void button1_Click(object sender, EventArgs e)
        {
            var from = numericUpDown1.Value;
            var to = numericUpDown2.Value;

            using (Form5 form5 = new Form5())
            {
                List<string> urls = new List<string>();

                foreach (ListViewItem item in form5.listView1.Items)
                {
                    foreach (ListViewItem.ListViewSubItem sub in item.SubItems)
                    {
                        if (String.Equals("0", sub.Text))
                        {
                            urls.Add(item.Text);
                        }
                    }
                }

                string[] items = urls.ToArray();

                foreach (string i in items)
                {
                    MessageBox.Show(i.ToString());
                }

            }

        }

But it doesn't work.. it doesn't show items that have "column2" as 0.

Please help me out.

You didnt say anything about the listView (as is in your code). And your explanation of the issue is very poor - hard to understand what exactly would you like to do. So lets go imagine...

EDIT (after some hours, when all was thought out well :) ):
you have 2 forms. On form1 you have a listBox. On form2 you have a listView, which has 2 columns. You open Form2, and do th selection in listView (could be multiple), and you want to pass data from column 2 to textBox on form1.
How close was that (but consider I had a hard time thinking what you hve had in mind)?

I'm sorry, it's listview not listbox. I edited my post.

YOu still didnt answer on my question. Anyway, I did your homework, and here it is:

//form1:
  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonOpenForm2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2(this);
            form2.Show();
        }

        public void PopultingListBox(List<string> list)
        {
            listBox1.Items.Clear();
            foreach (string item in list)
                listBox1.Items.Add(item);
        }
    }

//form2:
Form1 form1;
        public Form2(Form1 _form1)
        {
            InitializeComponent();
            form1 = _form1;

            listView1.Columns.Add("Column 1", 100, HorizontalAlignment.Left);
            listView1.Columns.Add("Column 2", 100, HorizontalAlignment.Center);
            listView1.View = View.Details;
            listView1.FullRowSelect = true;
            listView1.MultiSelect = true;

            PopulatingListView();
        }

        private void PopulatingListView()
        {
            string[] sArray = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            string[] iArray = new string[] { "0", "6", "8", "5", "2" };
            for (int i = 0; i < sArray.Length; i++)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = sArray[i];
                lvi.SubItems.Add(iArray[i]);
                listView1.Items.Add(lvi);
            }
        }

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

            //PASS DATA TO FORM1`S LISTBOX (FOR TEST):
            form1.PopultingListBox(list);
        }
    }

Hope it helps,
Mitja

Form6 is only the small windows (for export)? And the back form is form5?

But I still dont understand what are you trying to do here?
I need a better explanation. Sorry.
ps: explin this way that everyone can explain (with a bigger picture).

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.