I have a problem
My program has 2 form
1: form1 - main form
2: form3 - history browser - to load ariables from "database" (simple csv file) into form1 (Main) controls..

form3 should load and pass variables to form1 controls.text
I have only problem with ckheckedListBox in form3 - and I probably know why:

            Form1 f1 = new Form1(cfg_name);
            f1.comboBox_Maintenance_incident.Text = return_data[3];
            f1.comboBox_Type.Text = return_data[4];
            f1.comboBox_Affected_Item.Text = return_data[5];
            temp = return_data[6].Split(';');

                for (int i = 0; i < temp.Count(); i++)
                {
                    int index = 0;
                    foreach (object item in f1.checkedListBox_Items.Items)
                    {
                        if (temp[i] == item.ToString())
                        {
                            f1.checkedListBox_Items.SetItemChecked(index, true);
                        }

                        index++;
                    }



            }

This loop compare texts from temp array and if the that text matches with the text of any item from checklistbox - it ticks it.
the inner loop (foreach) even does not start...I suspect that it happens because Form1 is already closed - so there are no items to compare and to check if the condition is fullfilled..

I start form2 from main form - this way:

            Form3 f3 = new Form3();
            this.Hide();
            f3.Show();
            this.Close();
            f3.Activate();

thx for help in advance...I really dont know how to overcome my problem...To check items from other form without creating the new instance :(

Recommended Answers

All 2 Replies

Well. You can't pass information back to the main form if you close it.
You have already hidden it. Isn't that enough?

Suggestion. If the second form is nothing but a data retriever, sorter and parser, open it as a modal form instead and throw a progressbar on it or something and keep the main form open in the background.
When the job is done, close the second form from within itself.

I did it other way.
I just did a panel and throw everything threre.
Looks littlebit different - but its way easier to implement ..and the most important - IT WORKS :)

Thx for help btw :)

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.