J'ai un combobox qui suit les éléments insérésLes éléments statiquement insérés dans combobox double sur le clic de bouton pour plus d'une fois
public void SetOperationDropDown()
{
//ByDefault the selected text in the cmbOperations will be -SELECT OPERATIONS-.
cmbOperations.SelectedItem = "-SELECT OPERATIONS-";
//This is for adding four operations with value in operation dropdown
cmbOperations.Items.Insert(0, "PrimaryKeyTables");
cmbOperations.Items.Insert(1, "NonPrimaryKeyTables");
cmbOperations.Items.Insert(2, "ForeignKeyTables");
cmbOperations.Items.Insert(3, "NonForeignKeyTables");
cmbOperations.Items.Insert(4, "UPPERCASEDTables");
cmbOperations.Items.Insert(5, "lowercasedtables");
}
Mais que l'utilisateur clique sur le bouton plus d'une fois la valeur sera doublé ou tout chose indésirable arrive à la valeur.
le bouton clic
private void btnConnect_Click(object sender, EventArgs e)
{
//Function call for validating the textboxes entry
ValidateForm();
//Variable to store server address
string localHost = "192.168.10.3";
//Variable to store userId and password of the database
string logInDetails = "gp";
try
{
//Checking for the Valid entries in textboxes if all entries are correct then call functions accordingly
if((txtPassword.Text == logInDetails) && (txtUsername.Text == logInDetails) && (txtHost.Text == localHost))
{
//If connected then give this message to user
lblMessage.Visible = true;
lblMessage.Text = "You are connected to the SQL Server....";
if(lblMessage.Text != string.Empty)
{
//Function call for binding the dropdown with all DB names
BindDBDropDown();
//Function call for binding the operation names in dropdown
SetOperationDropDown();
}
}
else
{
//Else give the error message to user
lblMessage.Text = "Invalid Credentials";
}
}
catch(Exception ex)
{
//All the exceptions are handled and written in the EventLog.
EventLog log = new EventLog("Application");
log.Source = "MFDBAnalyser";
log.WriteEntry(ex.Message);
}
}
Quelqu'un peut-il me aider?
Quelle valeur est doublée? Et pouvez-vous expliquer un peu plus en détail ce qu'est une «chose indésirable»? –
les éléments dans le cmbOperations – Srivastava