Hi

I have a saved file like:

name - item1 - item2 -item3
name - item1 - item2 -item3
so on ....


Now i want to get like item1 to display in combobox. How can i do it??

Thx

If you mean that you have a file on a hdd, and you want to read out from it, then like this:

private static void ExerciseMethod()
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            using (System.IO.StreamReader sr = new System.IO.StreamReader(@"C:\1\FileExample.txt"))
            {
                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] array = line.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
                    list.Add(array[1].Trim());
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                string value = list[i].ToString();                
                this.comboBox1.Items.Add(value);
            }
        }

Hope this help you.

yeah this is what i meant

thx alot

Nice,
just mark the thread as salved, ok?
best regards,

Mitja

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.