hi guys i have getting problem
i want to transfer the item in listview to listbox and if the listbox already have that item it will count so that i can avoid double item what will happen to the text is it will display in the side of the item the number of times it was clicked

i have this code but is seems not working
how can i improve this?
Code:
private void listView1_DoubleClick(object sender, EventArgs e) 
        { 
            //get the string item of the selected item 
            string item = listView1.SelectedItems[0].ToString(); 
            int l = item.Length; 
            l -= 16; 
            string item2 = item.Substring(15,l); 
 
            //write the items from listbox to text file 
            int itemcounter = 0; 
            if (listBox1.Items.Count != 0) 
            { 
 for (string itemlist = listBox1.Items[itemcounter].ToString(); itemcounter <= listBox1.Items.Count; itemcounter++) 
                { 
                    writer = File.AppendText(tempfile); 
                    writer.WriteLine(itemlist); 
                    writer.Close(); 
                } 
            } 
 
            reader = new StreamReader(tempfile); 
            string hehe = reader.ReadToEnd(); 
             
 
            //compute for the Quantity 
 
            int lineCount = 0; 
            string line22 = String.Empty; 
            string line; 
 
            int lines = 1; 
 
 
             
 
            if (listBox1.Items.Count != 0) 
            { 
                while (line22 != item2 + "1") 
                { 
                    while ((line = reader.ReadLine()) != null) 
                    { 
                        lineCount++; 
                        if (lineCount == lines) 
                            line22 = line; 
                        lines++; 
                    } 
                } 
 
                lines--; 
                string removeitem = listBox1.Items[lines].ToString(); 
                listBox1.Items.Remove(removeitem); 
                listBox1.Items.Add("new item"); 
                 
            } 
            else 
            {  
                listBox1.Items.Add(item2 + "1"); 
            } 
            reader.Close(); 
            File.Delete(tempfile); 
             
        }

Last edited by shabbir; 10Jul2009 at 21:47.. Reason: Code blocks