private void OnChangeConnectionClick(object sender, EventArgs e) { using (var dlg = new ConnectionDialog(_server)) { if (dlg.ShowDialog(this.ParentForm) == DialogResult.OK) { _server.Server = dlg.Server; _server.User = dlg.UserName; _server.Password = dlg.Password; _server.AuthType = dlg.AuthType; var page = this.Parent as TabPage; var index = page.Text.IndexOf(" "); page.Text = _server.Server + page.Text.Substring(index); } } }