private void btnAdd_Click(object sender, EventArgs e) { TextForm tf = new TextForm(false); tf.Text = "Имя схемы"; if (tf.ShowDialog() == DialogResult.OK) { WatchingScheme ws = new WatchingScheme(watching.userId); ws.name = tf.TextValue; UpdateWatchingScheme(ws); using (GmConnection conn = App.CreateConnection()) { ws.Save(conn); } lbSchemes.Items.Add(ws); lbSchemes.SelectedItem = ws; } }
private void btnRename_Click(object sender, EventArgs e) { WatchingScheme ws = lbSchemes.SelectedItem as WatchingScheme; if (ws != null) { TextForm tf = new TextForm(false); tf.Text = "Имя схемы"; tf.TextValue = ws.Name; if (tf.ShowDialog() == DialogResult.OK) { ws.name = tf.TextValue; using (GmConnection conn = App.CreateConnection()) { ws.Save(conn); } lbSchemes.Items[lbSchemes.SelectedIndex] = ws; } } }