private void btnConfigure_Click(object sender, EventArgs e) { if (lvConnections.SelectedItems.Count > 0) { ConnectionInfo ci = (ConnectionInfo)lvConnections.SelectedItems[0].Tag; using (EditConnectionForm cef = new EditConnectionForm(ci)) { if (cef.ShowDialog() == DialogResult.OK) { lvConnections.SelectedItems[0].SubItems[0].Text = ci.Name; lvConnections.SelectedItems[0].SubItems[1].Text = ci.ConnectionDescriptor.GetDescription(); } } } lvConnections.Focus(); }
private void btnAdd_Click(object sender, EventArgs e) { ConnectionInfo ci = new ConnectionInfo(new MSSQLConnectionDescriptor(), GetNewConnectionEntryName(), ConnectionTypes.MSSQL, ""); using (EditConnectionForm cef = new EditConnectionForm(ci)) { if (cef.ShowDialog() == DialogResult.OK) { ListViewItem lvi = lvConnections.Items.Add(ci.Name); lvi.SubItems.Add(ci.ConnectionDescriptor.GetDescription()); lvi.Tag = ci; lvi.Selected = true; Program.Connections.Add(ci); } } lvConnections.Focus(); }