private void bt_serverEdit_Click(object sender, EventArgs e) { if (dataGrid_servers.SelectedRows.Count == 1) { var currentServser = dataGrid_servers.SelectedRows[0].DataBoundItem as Servers; ServersEdit edit = new ServersEdit(currentServser); edit.ShowDialog(); dataGrid_servers.Refresh(); } else { MessageBox.Show("must select server!"); } }
private void bt_add_server_Click(object sender, EventArgs e) { if (dataGrid_accounts.SelectedRows.Count == 1) { var sel = dataGrid_accounts.SelectedRows[0].DataBoundItem as Accounts; var currentDelegate = new DelegateServers(); foreach (DelegateServers s in delegateServers) { if (s.account.username == sel.username) { currentDelegate = s; break; } } if (currentDelegate.servers == null) { currentDelegate.servers = new List <Servers>(); } Servers newServer = new Servers(); newServer.serverName = "new server"; currentDelegate.servers.Add(newServer); BindAccounts(); BindServers(); ServersEdit edit = new ServersEdit(newServer); edit.ShowDialog(); dataGrid_servers.Refresh(); } else { MessageBox.Show("must select account!"); } }