private void addButton_Click(object sender, EventArgs e) { if (xdata != null) { if (!xdata.HasXData()) { MessageBox.Show("该实体没有扩展数据,请注册应用程序名"); newAppButton.Focus(); return; } AddParamsForm addParamsForm = new AddParamsForm(xdata); Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(addParamsForm); if (addParamsForm.Param == null || addParamsForm.Value == null) { // do nothing } else { xdata.AddXData(addParamsForm.Param, addParamsForm.Value); ListViewItem item = new ListViewItem(); item.SubItems[0].Text = addParamsForm.Param; item.SubItems.Add(addParamsForm.Value); if (this.xdataListView.SelectedItems.Count > 0) { int index = this.xdataListView.SelectedItems[0].Index + 1; this.xdataListView.Items.Insert(index, item); } else { this.xdataListView.Items.Add(item); } } } else { MessageBox.Show("必须选择一个实体"); this.selectButton.Focus(); } }