private void button_modify_Click(object sender, EventArgs e) { string strError = ""; if (this.listView_entities.SelectedItems.Count == 0) { strError = "尚未选择要修改的事项"; goto ERROR1; } ListViewItem item = this.listView_entities.SelectedItems[0]; EntityDialog dlg = new EntityDialog(); dlg.Entity = item.Tag as Entity; dlg.ShowDialog(this); if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel) { return; } SetListViewItem(item, dlg.Entity); return; ERROR1: MessageBox.Show(this, strError); }
private void button_new_Click(object sender, EventArgs e) { EntityDialog dlg = new EntityDialog(); dlg.ShowDialog(this); if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel) { return; } ListViewItem item = new ListViewItem(); SetListViewItem(item, dlg.Entity); this.listView_entities.Items.Add(item); this.listView_entities.SelectedIndices.Clear(); ListViewUtil.BeginSelectItem(this.listView_entities, item); }