void getAddConfFiles(ArrayList al) { for (int i = 0; i < al.Count; i++) { string filepath = al[i] as string; bool ishave = false; for (int j = 0; j < listviewitems.Count; j++) { Update_File uf = listviewitems[j] as Update_File; if (filepath.Equals(uf.Fileurl)) { ishave = true; break; } } if (!ishave) { string[] temp = filepath.Split('\\'); string filename = temp[temp.Length - 1]; listviewitems.Add(new Update_File() { Name = filename, Fileurl = filepath }); } } this.listBox1.DataSource = null; this.listBox1.DataSource = listviewitems; this.listBox1.DisplayMember = "Name"; this.listBox1.ValueMember = "Fileurl"; this.listBox1.SelectedItem = null; this.listBox1.Refresh(); }
void ListBox1SelectedIndexChanged(object sender, EventArgs e) { if (lastFile != null && this.textBox2.Text != null) { int a = this.listviewitems.IndexOf(lastFile); if (a >= 0) { listviewitems[a].ConfContent = this.textBox2.Text; } } if (this.listBox1.SelectedItem != null) { Update_File uf = this.listBox1.SelectedItem as Update_File; this.textBox1.Text = uf.Fileurl; this.textBox2.Text = uf.ConfContent; lastFile = uf; } }