//Renewing the list of the combo box for displaying different database name. public void refreshComboBox() { cmb_databaseNames.Items.Clear(); List <string> databaseNames = getDatabases(); foreach (string tn in databaseNames) { NameValue n1 = new NameValue(tn, tn); cmb_databaseNames.Items.Add(n1); } cmb_databaseNames.Text = ""; cmb_databaseNames.SelectedIndex = 0; }
//Refreshes the combo box with up to date list of tables public void refreshComboBox() { cmb_TableNames.Items.Clear(); List <string> tableNames = Program.getTablesInDatabase(); foreach (string tn in tableNames) { NameValue n1 = new NameValue(tn, tn); cmb_TableNames.Items.Add(n1); } cmb_TableNames.Text = ""; if (cmb_TableNames.Items.Count > 0) { cmb_TableNames.SelectedIndex = 0; } }
//Form for displaying table data private void frm_Main_Load(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.FixedSingle; //males the combo box select only cmb_TableNames.DropDownStyle = ComboBoxStyle.DropDownList; //initialize the combo box values List <string> tableNames = Program.getTablesInDatabase(); foreach (string tableName in tableNames) { NameValue n1 = new NameValue(tableName, tableName); cmb_TableNames.Items.Add(n1); } if (cmb_TableNames.Items.Count > 0) { cmb_TableNames.SelectedIndex = 0; } }