private void renameCategoryButton_Click(object sender, EventArgs e) { ListItemWithId category = (ListItemWithId)categorySelector.Items[categorySelector.SelectedIndex]; UserInputDialog dialog = new UserInputDialog(); dialog.Text = "Rename " + category.Text; dialog.CaptionText = "Enter new name for " + category.Text; dialog.InputText = category.Text; if (dialog.ShowDialog() == DialogResult.OK) { string newCategoryName = dialog.InputText; database.RenameCategory(category.Id, newCategoryName); categorySelector.Items[categorySelector.SelectedIndex] = new ListItemWithId(newCategoryName, category.Id); } }
private void newCategoryButton_Click(object sender, EventArgs e) { UserInputDialog dialog = new UserInputDialog(); dialog.Text = "New Category"; dialog.CaptionText = "Enter name for new category"; if (dialog.ShowDialog() == DialogResult.OK) CreateNewCategory(dialog.InputText); }