Mitja Bonca 557 Nearly a Posting Maven

I would stronglly reccomend, what has abelLazm proposed you, to change the event. Do not use SelectedIndexChaged, becuase you will have only problems. Use Click event.
What is the problem with SelectedIndexChnaged event is that it wires twice for the row selection. When you clik the listView for the 1st time it fires ones - thats ok, but as soon as you click it for the 2nd time, it will fire for the 1st clicked row, and for the 2nd time for the newly clicked row. So it can make your life very miserable, if oyur dont know how to handle it.

As said, use Click event and all will be fine - its the same thing.

I did an example code how to get items and subitems from lisrView:

public Form1()
        {
            InitializeComponent();

            listView1.Columns.Add("Column1", 100, HorizontalAlignment.Left);
            listView1.Columns.Add("Column2", -2, HorizontalAlignment.Center);
            listView1.View = View.Details;
            listView1.FullRowSelect = true;

            //add some example rows:
            for (int i = 1; i < 5; i++)
            {
                ListViewItem lvi = new ListViewItem(i.ToString() +".");
                lvi.SubItems.Add("Column 2 - " + i);
                listView1.Items.Add(lvi);
            }

            listView1.Click += new EventHandler(listView1_Click);
        }

        private void listView1_Click(object sender, EventArgs e)
        {
            string col1 = listView1.SelectedItems[0].Text;
            string col2 = listView1.SelectedItems[0].SubItems[1].Text;

            MessageBox.Show("1st column: " + col1 + "\n2nd column: " + col2);
        }
Mitja Bonca 557 Nearly a Posting Maven

If I understand you, you have 2+ columns in listView. And you would like to get the values from column1, column2, ... (if they are).
Am I right?

Mitja Bonca 557 Nearly a Posting Maven
if (listView1.SelectedItems[0].SubItems[0].Text.ToString()) //...

Items or SelectedItems means 1st column, SubItems are 2nd and more columns, depends which index do you specify in the brackets.
SubItems[0] is 1st column, same as Items[0], so you have 2 options:
1. for choosing 1st column value : .SelecteItems[0].Text;
2. or choosing 2nd (or more) column value: .SelectedItems[0].SubItems[1].Text;
2.1 for choosing a value from the 3rd column: .SelectedItems[0].SubItems[2].Text;

I hope we clerified about Items and SubItems properties of the listView.

Mitja Bonca 557 Nearly a Posting Maven
DateTime Staff_Total_Hours = (Convert.ToDateTime(textBox1.Text)).ToTimeSpan().Add(  (Convert.ToDateTime(txtTime.Text)).ToTimeSpan());

does not solve the problem

Dont you see my post on this 2nd page on the top? This is your solution.

Mitja Bonca 557 Nearly a Posting Maven
List<string> list1 = new List<string>();
            List<string> list2 = new List<string>();
            string a = "100000";
            string b = "011111";
            string[] array = new string[]{a,b};
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i][0].ToString() == "1")
                    list1.Add(array[i]);
                else
                    list2.Add(array[i]);
            }
Mitja Bonca 557 Nearly a Posting Maven

I have read your 1st post, and this is the colution for your troubles: :)

DateTime hour1 = Convert.ToDateTime(textBox1.Text);
 DateTime hour2 = Convert.ToDateTime(textBox2.Text);
 hour1 = hour1.AddHours(hour2.Hour).AddMinutes(hour2.Minute).AddSeconds(hour2.Second);
 MessageBox.Show("Total date with hours is: " + hour1);

AS you can see, you have to convert both values to dateDate format. Then you have to add every sinlge date and/or time value to the date you want to "sum up". On this way you can add even years, months, miliseconds,..

bye, bye

Mitja Bonca 557 Nearly a Posting Maven

Would you like to sum hours? I what format do you have hours?

In one textBox1 you have "10:00:00", that means "hour is 10am". What is in the 2nd textBox2?

Mitja Bonca 557 Nearly a Posting Maven

YOu cannot use + operator on DateTime. What exactly would you like to do?

Mitja Bonca 557 Nearly a Posting Maven

You can use String.Format method, but it will return a string value of the time (not an actual time).

DateTime date = DateTime.Now;
string strTime = String.Format("{dd.MM.yyyy hh:mm}", date);

Do you explicitly wanna have a DateTime, and now a string?

If you only wanna add time (hours) you can simply use Add method in the time:

DateTime newTime = date.AddHours(2);
Mitja Bonca 557 Nearly a Posting Maven

This code is better, it checks if the item exists in listView2. If it does not exists, it adds the item to listView2, if it exists, it does NOT add (it skips that one):

//code in the button click event:
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].Checked)
                {
                    string _item = listView1.Items[i].SubItems[1].Text;
                    
                    //checking if this item exists in listView2:
                    //if not, its added to listView2
                    bool bInsert = true;
                    for (int j = 0; j < listView2.Items.Count; j++)
                    {
                        if (listView2.Items[j].Text == _item)
                        {
                            bInsert = false;
                            break;
                        }
                    }
                    if (bInsert)
                        listView2.Items.Add(_item);
                }
            }
Mitja Bonca 557 Nearly a Posting Maven
public Form1()
        {
            InitializeComponent();

            listView1.Columns.Add("Checking", 50, HorizontalAlignment.Center);
            listView1.Columns.Add("Item name", -2, HorizontalAlignment.Center);
            listView1.View = View.Details;
            listView1.CheckBoxes = true;

            listView2.Columns.Add("Item name", 100, HorizontalAlignment.Center);
            listView2.View = View.Details;

            //add some items to listView1:
            for (int i = 0; i < 5; i++)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.SubItems.Add("Item " + i + 1);
                listView1.Items.Add(lvi);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].Checked)
                {
                    listView2.Items.Add(listView1.Items[i].SubItems[1].Text);
                }
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

This code is not so good. You have already opened Form1, and its not a good practice to create a new instance of Form1.
Better would be as I showed you, to pass an instance of form1 as parameter to the class, where you would like to use it,

private void button1_Click(object sender, EventArgs e)
        {
            OtherClass otherclass = new OtherClass(this);//ADDED this- its a instance of Form1
            NewThread = new Thread(new ThreadStart(otherclass.MyNewThread));
            NewThread.Start();
        }

////////////////////////
    public class OtherClass
    { 
        Form1 form1;
        //constructor:
        public OtherClass(Form1 _f1)
        {
          this.form1 = _f1;
        }
        public void MyNewThread()
        {
            Console.WriteLine("in OtherClass"); //my thread has started as this shows up in output            
            form1._UpdateLabel("New Text"); // This does not update the label text
        }
    }
Suzie999 commented: very very helpful info to a newb like me. +1
Mitja Bonca 557 Nearly a Posting Maven

If I understand you well, you would like to update a label on from1 from some other form, am I right?
For this you do not need delegates at all, and you do not need to start a new Thread either.
You can do it:

//form1:
public void UpdateLabel(string item)
{
    this.label1.Text = item;
}

//form2:
Form1 f1;
public Form2(Form1 _f1)
{
    //constructor of form2
    Initializecomponent();
    this.f1 = _f1;
}

private void button1_ClickUpdateLabelOnform1(objec sender, EventArgs e)
{
    f1.UpdateLabel("New text to pass to form1 form form2");
}

Thats it.

Mitja Bonca 557 Nearly a Posting Maven

Best would be to give us the code. Then we can point you into the righ direction...

Mitja Bonca 557 Nearly a Posting Maven

Instead of using array, I would STRONGLY recommend you to use generic list instead. Its a WAY better "tool" to work with. Some exercise will sure be needed, but on the end you will be greatful to me, you will see :)

Ok, here`s the code I would like you to study:

class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter number of employees:");
            Console.WriteLine("-------------------------");
            int all = Convert.ToInt32(Console.ReadLine());

            List<Employee> list = new List<Employee>();
            string value;
            for (int i = 0; i < all; i++)
            {
                Employee e = new Employee();
                Console.WriteLine("Employee No.{0}:", i + 1);
                Console.WriteLine("Enter user`s name:");
                value = Console.ReadLine();
                e.Name = value;
                Console.WriteLine("Enter user`s age:");
                value = Console.ReadLine();
                e.Age = int.Parse(value);
                list.Add(e);
            }
            Console.WriteLine("Thx for insertions...");
            Console.WriteLine(".....................");
            Console.WriteLine("Here are the results:");
            foreach (Employee e in list)
                Console.WriteLine("Employee {0} is {1} old", e.Name, e.Age);
            Console.ReadLine();
        }
    }

    class Employee
    {       
        public string Name { get; set; }
        public int Age { get; set; }
    }

Dont forget to do the checking of the numbers. In case if the user enters a string while integer expected, there will be an error.

Mitja Bonca 557 Nearly a Posting Maven

Did you think of something like this:

class Program
    {
        static void Main(string[] args)
        {
            List<Employee> list = new List<Employee>();
            //lets add some data
            list.AddRange(new Employee[]{
                new Employee {ID = 1, Name = "John", Age= 28 },
                new Employee {ID = 2, Name = "Ann", Age= 22 },
                new Employee {ID = 3, Name = "George", Age= 30 } 
            });

            Console.WriteLine("Please enter the id of the employee to get this data:");
            int id = int.Parse(Console.ReadLine());
            var userData = list.Where(w => w.ID == id).ToList();
            foreach (var data in userData)
                Console.WriteLine("Name is : {0}, Age is: {1}.", data.Name, data.Age);
            Console.ReadLine();
        }
    }

    class Employee
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }
Mitja Bonca 557 Nearly a Posting Maven

...for the employee by Asking the user to enter the number of employees.

What does it mean to enter the number of employees?

Mitja Bonca 557 Nearly a Posting Maven

Instead of using that if statement:

if (Regex.IsMatch(allRead, regMatch))

I would suggest you, before doing a loop create an array of all characters (all the words in that string) :

string allRead = testTxt.ReadToEnd();
string allChars = allRead.Split(' ');
//create a new string wtih htmls:
string newString  = null;
//your html string:
string htmlString = "Y:\\WorleyParsons\\Sasol Unit 17\\Submission Data\\Tru-View\\Unit17TruViewInterface\\TruView\\Unit17\\SiteMap.htm";
StringBuilder sb = new StringBuilder();

for(int i = 0; i < allChars.Lenght; i++)
{
    //here do the Regex, or simple string Contains method checking
    //if the char is your tag, add the html link:
    //add the char:
    sb.AppendText(allChars[i].ToString);
    //and add the html link if "the e" is found:
    if(allChars[i].Contains("e"))
        sb.AppendText(htmlString); 
}
//add newly created string from StringBuilde to a "newString" variable:
string newString = sb.Tostring();

This code i did heart, so there can be errors. I appologize for that.
But this is an example code how you can add your string into string.

Mitja Bonca 557 Nearly a Posting Maven

Try it this way:

string path = @"C:myFolder\myFile.txt";
            List<int> list = new List<int>();
            using (StreamReader sr = new StreamReader(path))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                    list.Add(Convert.ToInt32(line));
            }

            //generic list<T> now has all the numbers in the collection! 
            //generic list is better then a simple array (int[]).
Mitja Bonca 557 Nearly a Posting Maven

Yes, my csv file was slitted with semicolon. Im really glad you find the cause of the problem. This is only best for you, because this way you will learn the most. And do not forget to use Breakpoints (always), if you dont use them already.

Mitja Bonca 557 Nearly a Posting Maven

Now you habe to figue out what exactly do you get into some variables. Of course you will get this error, if the value is not an integer (full number, with no decimals, and no string at all).

The code we will provide you, it will never work for 100%, until you will not understand the concept of the code. Until then, its worthless. There will always be something that it will interupt your code.
I cannot help you here, especiually because the code I gave you, it WAS WORKING 100%, and now you are saying its not working. Well then its not working. Find out why its not working. Spend some 10s of hours on the project and find out what is the matter. You are the one who has to understand the code here, and faster you will get it, better you you will be - believe me.

So, back to your issue:
As said. the value that is now in the "lineValues[j]" it is NOT an integer. You find out how its possible that some other type of value came into it. It surely is not my exmaple code you gave me, otherwise this wouldn`t have happened.

Mitja Bonca 557 Nearly a Posting Maven

Man, again and again. One question for 2 weeks now. Please get some books and start learing by your self. We cannot teach you all here. We are here to help, not to teach ppl.
I wont answer on these kind of threads any longer. I think I gave given you more then enough, and if you still havent figured it out by now, this is not my problem. Sorry for sounding a bit harsh, but I simply dont like the way you are "forcing" us to do all the code you need instead of you.
bye

Mitja Bonca 557 Nearly a Posting Maven

If you want to pass the value from form1 to form2 when the form2 is opened, you can use this kind of code:

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

        private void button1_Click(object sender, EventArgs e)
        {
            if (f2 == null)
                f2 = new Form2();
            f2.ValueFromForm1(textBox1.Text);
            f2.Show();
        }
    }

//form2:
 public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public void ValueFromForm1(string value)
        {
            textBox1.Text = value;
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

You do:

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

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(textBox1.Text);
            f2.Show();
        }
    }

//form2:

    public partial class Form2 : Form
    {
        public Form2(string value)
        {
            InitializeComponent();
            textBox1.Text = value;
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

Maybe you are dont use Linq namespace:

using System.Linq; //add this on the top of the class

Or you use 1.1 VS, becuase 2.0 has Linq included

Same solution would be :

dic[j]+= intValue;
Mitja Bonca 557 Nearly a Posting Maven

This was the code I did for him, and I used a Linq there (dont know why, just spontaniously I guess, even if your way is good the same way - just to assign new value to the appropriate key).

Is it working now? It surely was working before too. I tested it.

Mitja Bonca 557 Nearly a Posting Maven

I showed you in the code I gave you in some other thread. I was using dictionary collection to get the values of the columns (and a sum of them).

Mitja Bonca 557 Nearly a Posting Maven

Here is the code you want. But I find it hard that you will underatand it:

string path = @"C:\1\";
            string[] file1_Lines = File.ReadAllLines(path + @"TraceSet.csv");
            string file2 = File.ReadAllText(path + @"SBoxOutput.csv");
            string[] file2_Lines = file2.Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
            
           //creating 2 lists for average values of file1 and file2:
            List<float> averageFile1 = new List<float>();
            List<float> averageFile2 = new List<float>();

            //filling list1 - with average calculation of the file1 (row average):
            foreach (string line in file1_Lines)
            {
                string[] columns = line.Split(';');
                float fAvg = 0f;
                for (int i = 1; i < columns.Length; i++)
                {
                    float value = Convert.ToSingle(columns[i]);
                    fAvg += value;
                }
                //get the average and add to list:
                fAvg = fAvg / (columns.Length - 1);
                averageFile1.Add(fAvg);
            }

            //filling list2 - with average calculation of the file2 (column average):
            //creating a dictionary collection for get the sum of values in the columns
            Dictionary<int, int> dic = new Dictionary<int, int>();
            for (int i = 0; i < file2_Lines.Length; i++)
            {
                string[] lineValues = file2_Lines[i].Split(';');
                for (int j = 0; j < lineValues.Length; j++)
                {
                    int intValue = Convert.ToInt32( lineValues[j]);
                    if (dic.ContainsKey(j))
                        dic = dic.ToDictionary(d => d.Key, d => d.Key == j ? d.Value + intValue : d.Value);
                    else
                        dic.Add(j, intValue);
                }
            }
            
            //get the average into the list2 from the dictionary:
            int rows = file2_Lines.Length;
            foreach (KeyValuePair<int, int> _value in dic)
            {
                averageFile2.Add(_value.Value / rows);
            }

            //
            //
            //subtract the average of row 1 from the average of column 1 and reapeat for each row and column 
            //
            List<float> newList = …
Mitja Bonca 557 Nearly a Posting Maven

then subtract the average of row 1 from the average of column 1
and reapeat for each row and column...

From which row, and from which column? Please be more specific!!!

Mitja Bonca 557 Nearly a Posting Maven

Not a good example, sorry. Why? No need to explaining.

Mitja Bonca 557 Nearly a Posting Maven

Im not sure where would you like to put the calulated value, but this is how to be done, and like you already did it:

foreach (string item in rowVals)
                    {
                        try
                        {
                            float num = float.Parse(item);
                            sum += num;
                            addedItems++;
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }

You have to get the other value (let say "num" is value A), value B. And the you subtract one from antoher. The value you will get, put into a new arraylist.

Btw, I know you have no idea how to do it, it would be best to show me how the csv file is made, so I can show you on the exmple code.

Mitja Bonca 557 Nearly a Posting Maven

It doesnt matter if are constant or not. As long as the value is a type of float (or decimal, or even some other math type), you can do marh operations over them.
So you only have to get two varibles, and do a substraction over them. New value will be saved into an array list (or where ever you want it).

Mitja Bonca 557 Nearly a Posting Maven

You type float (if you have decimals), or decimal:

float a = 0.564F;
 float b = 0.356F;
 float c = a - b;
Mitja Bonca 557 Nearly a Posting Maven

Check out this code:

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

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp";
            // Allow the user to select multiple images.
            open.Multiselect = true;
            open.Title = "Image browser";

            if (open.ShowDialog() == DialogResult.OK)
            {
                foreach (String file in open.FileNames)
                {
                    string fullfileName = System.IO.Path.GetFullPath(file);
                    string showFileName = System.IO.Path.GetFileName(file);

                    comboBox1.Items.Add(new ComboBoxItems { FullPath = fullfileName, FileName = showFileName });
                }
                comboBox1.DisplayMember = "FileName";
                comboBox1.ValueMember = "FullPath";
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string filePath = (comboBox1.SelectedItem as ComboBoxItems).FullPath;
            if (filePath != String.Empty)
            {
                pictureBox1.Image = new Bitmap(filePath);
                this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            }
        }
    }
    class ComboBoxItems
    {
        public string FullPath { get; set; }
        public string FileName { get; set; }
    }
Mitja Bonca 557 Nearly a Posting Maven

Heres an example:

List<Form> list = new List<Form>();
            foreach (Form f in Application.OpenForms)
                if (f.Name == "Form2")
                    list.Add(f);

            //close seleced (in this case only FindFrm will be closed:
            foreach (Form f in list)
                f.Close();

Maybe some forms do not have set the NAME propety. So you will have to set it manually in some place of form creation. Best it to put the code into "FormName.Designer" class:

//where is this code:
this.Text = "FindFrm";
//put this code too:
this.Name = "FindFrm";
Mitja Bonca 557 Nearly a Posting Maven

This is not a good way to close the form. You better do a loop of all forms, and then check which you want to select. Selected put into an array (pre-created), and when the code goes throught the loop (when it ends), go through the array of forms, and close them.
Array has to be created and put the forms inside, because you are not allows to change the state of the forms (in your case closing them) while in foreach loop. You will get an error.
Hope it helps explaing how to close opened forms.

Mitja Bonca 557 Nearly a Posting Maven

Try it this way:

private void button1_Click(object sender, EventArgs e)
        {
            Label l = new Label();
            l.Location = new Point(100, 100);
            l.Text = "This is a text";
            this.Controls.Add(l);
        }
Mitja Bonca 557 Nearly a Posting Maven

Check this example:

string[] array1 = { "12345", "145", "1345" };
            string second= "23";
            int sum = 0;
            foreach (string item in array1)
            {
                if (item.Contains(second))
                    sum++;
            }
            MessageBox.Show("There is/are " + sum + " strings of \"" + second + "\" string in the array.");
Mitja Bonca 557 Nearly a Posting Maven

or:

double min = sortList.Min(x => x.Value);
Mitja Bonca 557 Nearly a Posting Maven

Get the states based on selected country to populate comboBox2:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlDataAdapter da1 = new SqlDataAdapter("select State from States where country_name='" + combobox1.SelectedItem.ToString() + "'", "Data Source=.;Initial Catalog=master;Integrated Security=True;");
            da1.Fill(ds1);
            int i = ds1.Tables[1].Rows.Count;

            for (int s = 0; s < i; s++)
            {
                comboBox2.Items.Add(ds1.Tables[1].Rows[s][1]);
            }
        }

Then you geta all cities based on selected state:

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlDataAdapter da1 = new SqlDataAdapter("select City_name from Cities where State_Name ='" + combobox2.Selecteditem.ToString() + "'", "Data Source=.;Initial Catalog=master;Integrated Security=True;");
            da1.Fill(ds1);
            int i = ds1.Tables[2].Rows.Count;

            for (int s = 0; s < i; s++)
            {
                comboBox3.Items.Add(ds1.Tables[2].Rows[s][1]);
            }
        }

Table for index 0 is for the Countries, table at index 1 is for the states, and table at index 2 is for the cities (table[0], table[1], table[2]).

Mitja Bonca 557 Nearly a Posting Maven

No problem. Just thread as answered (or vote as useful), to close the thread.
bye

Mitja Bonca 557 Nearly a Posting Maven

You didnt even set the min value until here. It is still 0 (or not even that, because you didnt initialize it). So you cannot compare it (if(v > min)!

Mitja Bonca 557 Nearly a Posting Maven

Wrong. You have to put a property of a textbox control on the end of it to check it:

if(textBox.Text != String.Empty)
{
   //not empty (not null, even empty and null are not the same things)
}
else
{
   //empty!
}
Mitja Bonca 557 Nearly a Posting Maven

YOu forgot to include ' ' to the query around property textbox.Text). Your create query has to look like:

sq1 = "CREATE TABLE '" + TextBox1.Text + "'(myId INTEGER CONSTRAINT PKeyMyId PRIMARY KEY," +"myName CHAR(50), myAddress CHAR(255), myBalance FLOAT)";
Mitja Bonca 557 Nearly a Posting Maven

Simple:
Constructor is only a method, which has this previlege that is called first when a new instance of a class (or form) is created. It is called automatically when this instance gets created.

Mitja Bonca 557 Nearly a Posting Maven

Check out this code:

public partial class Form1 : Form
    {
        Dictionary<string, double> dic = new Dictionary<string, double>();
        public Form1()
        {
            InitializeComponent();
            listBox1.Items.AddRange(new string[] { "{1 2} 4", "{1 4} 6", "{1 5} 7", "{1 3 4} 8" });
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string line = listBox1.SelectedItem.ToString();
            string _key = Regex.Match(line, @"{(.*?)}").Groups[1].Value;
            string _value = line.Remove(0, ((line.IndexOf("}") + 2)));
            double dValue = 0;
            if (double.TryParse(_value, out dValue))
            {
                if (dic.ContainsKey(_key))
                    dic[_key] = dValue;
                else
                    dic.Add(_key, dValue);

                //I will even remvoe the selected item from the listBox (so you donw have duplicates).
                //If you dont want to remove, simply dont use this code.
                listBox1.Items.Remove(line);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //check what have you stored into the dictionary:
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("These is what you have stored into the dictionary<string, double> :");
            foreach (KeyValuePair<string, double> kvp in dic)
            {
                sb.AppendLine(String.Format("Key: {0}, Value: {1}", kvp.Key, kvp.Value));
            }
            MessageBox.Show(sb.ToString());
        }
    }

Mitja

Mitja Bonca 557 Nearly a Posting Maven

The listbox content is as below:
{1 2} 4
{1 4} 6
{1 5} 7
{1 3 4} 8

1st column is what is in the brackets? And the value out of brackets is your 2nd column, which would be the Value of the dictionary?

Mitja Bonca 557 Nearly a Posting Maven

Here is the colution:

private void dataGridView1_CellClick(object obj, DataGridViewCellEventArgs e)
        {
             int rowindex = e.RowIndex;
            List<object> data = new List<object>();
            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                if (rowindex == row.Index)
                {
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        //SET INDEXES OF THOSE 2 COLUMNS WHERE YOU HAVE ID AND NAME
                        //my example code shows 1st and 2nd column (indexes of 0 and 1):
                        if (e.ColumnIndex == 0 && e.ColumnIndex == 1) 
                            data.Add(cell.Value.ToString());
                    }
                    break;
                }
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

So get only data from those 2 columns where is ID and a Name.

Mitja Bonca 557 Nearly a Posting Maven

simply hide the form2 (which will show from1). And when you need to show form2 again, just call form2.Show() method. thats it.

Mitja