private void SQLServerComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.SQLServerComboBox.SelectedItem != null && this.SQLServerComboBox.SelectedItem is string) { this.SQLDatabaseComboBox.Enabled = false; this.SQLDatabaseComboBox.SelectedItem = null; this.SQLDatabaseComboBox.Text = ""; this.SQLDatabaseComboBox.Items.Clear(); Application.DoEvents(); Cursor.Current = Cursors.WaitCursor; string serverName = this.SQLServerComboBox.SelectedItem as string; foreach (string databaseName in SqlServerLocator.FindDatabases(serverName)) { this.SQLDatabaseComboBox.Items.Add(databaseName); } if (this.SQLDatabaseComboBox.Items.Count > 0) { this.SQLDatabaseComboBox.SelectedItem = this.SQLDatabaseComboBox.Items[0]; } this.SQLDatabaseComboBox.Enabled = true; Cursor.Current = Cursors.Default; } }
private void SQLServerComboBox_DropDown(object sender, System.EventArgs e) { if (this.refreshServerListOnDropDown) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); ArrayList servers = SqlServerLocator.FindServers(); SQLServerComboBox.Items.Clear(); foreach (string server in servers) { if (server.ToLower() == "(local)") { SQLServerComboBox.Items.Add(Environment.MachineName.ToUpper()); } else { SQLServerComboBox.Items.Add(server); } } this.Cursor = Cursors.Default; this.refreshServerListOnDropDown = false; } }