private void buttonEdit_Click(object sender, System.EventArgs e) { FormEnter form = new FormEnter(); form.StartPosition = FormStartPosition.CenterParent; form.Text = "Edit"; ListViewItem listViewItem = fadingListView.SelectedItems[0]; form.Firstname = listViewItem.SubItems[0].Text; form.Lastname = listViewItem.SubItems[1].Text; form.Datatag = (string)FadingListView.GetTag(listViewItem); form.Age = int.Parse(listViewItem.SubItems[2].Text); if (form.ShowDialog(this) == DialogResult.OK) { listViewItem.SubItems[0].Text = form.Firstname; listViewItem.SubItems[1].Text = form.Lastname; listViewItem.SubItems[2].Text = form.Age.ToString(); FadingListView.SetTag(listViewItem, form.Datatag); fadingListView.ChangeItem(listViewItem); textBoxTag.Text = form.Datatag; } }
private void buttonAdd_Click(object sender, System.EventArgs e) { FormEnter form = new FormEnter(); form.StartPosition = FormStartPosition.CenterParent; form.Text = "Add"; Random random = new Random(); form.Firstname = RandomString(unchecked ((int)DateTime.Now.Ticks / 7)); form.Lastname = RandomString(unchecked ((int)DateTime.Now.Ticks / 5)); form.Datatag = RandomString(unchecked ((int)DateTime.Now.Ticks / 3)); form.Age = random.Next(100); if (form.ShowDialog(this) == DialogResult.OK) { ListViewItem listViewItem = new ListViewItem(new string[] { form.Firstname, form.Lastname, form.Age.ToString() }); fadingListView.AddItem(listViewItem); FadingListView.SetTag(listViewItem, form.Datatag); } }