private void bEdit_Click(object sender, EventArgs e) { if (olvCustomColumns.SelectedObject == null) return; int index = olvCustomColumns.SelectedIndex; KeyValuePair<string, string> selectedItem = (KeyValuePair<string, string>)olvCustomColumns.SelectedObject; using (AddCustomColumnDialog dialog = new AddCustomColumnDialog()) { dialog.ColumnName = selectedItem.Key; dialog.ColumnValue = selectedItem.Value; dialog.Text = "Edit " + selectedItem.Key; if (dialog.ShowDialog(this) == DialogResult.OK) { this.cachedCustomColumns.Remove(selectedItem.Key); this.cachedCustomColumns[dialog.ColumnName] = dialog.ColumnValue; this.olvCustomColumns.SetObjects(cachedCustomColumns); this.olvCustomColumns.SelectedIndex = index; this.customColumnsChanged = true; } } }
private void bAddCustomColumn_Click(object sender, EventArgs e) { using (AddCustomColumnDialog dialog = new AddCustomColumnDialog()) { if (dialog.ShowDialog(this) == DialogResult.OK) { this.cachedCustomColumns[dialog.ColumnName] = dialog.ColumnValue; this.olvCustomColumns.SetObjects(cachedCustomColumns); this.customColumnsChanged = true; } } }