private void btnEdit_Click(object sender, EventArgs e) { if (lbCoordinates.SelectedIndex != -1) { var selectedItem = (ClickPoint)lbCoordinates.SelectedItem; using (var d = new AddEditForm(selectedItem, true)) { var id = ThisProgrammConfig.ClickPoints .FindIndex(a => a == selectedItem); if (d.ShowDialog() == DialogResult.OK) { ThisProgrammConfig.ClickPoints[id] = new ClickPoint { Name = d.Name, X = d.X, Y = d.Y }; } RefreshListBoxDataBinding(); lbCoordinates.SelectedIndex = id; } } else { MessageBox.Show( "You must select item in list first!", "Error in selection", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAdd_Click(object sender, EventArgs e) { using (var d = new AddEditForm( new ClickPoint { X = (int)nudX.Value, Y = (int)nudY.Value })) { if (d.ShowDialog() == DialogResult.OK) { ThisProgrammConfig.ClickPoints.Add( new ClickPoint { Name = d.Name, X = d.X, Y = d.Y }); RefreshListBoxDataBinding(); } } }