Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3485538
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:55:11+00:00 2026-05-18T10:55:11+00:00

I have a combobox that has following items inserted public void SetOperationDropDown() { //ByDefault

  • 0

I have a combobox that has following items inserted

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");
    }

But as the user clicks on the button more than once the value gets doubled or any unwanted thing happens to the value.

the button click is

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);
        }
    }

Can anyone help me out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:55:12+00:00Added an answer on May 18, 2026 at 10:55 am
    public void SetOperationDropDown()
    {
    if(CmbOperations.Items.Count == 0)
    {
    //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"); 
    
    
    }
    else
    {
    int? cbSelectedValue = null;
    if(!string.IsNullOrEmpty(cmbOperations.SelectedValue))
    cbSelectedValue = convert.toInt32(cmbOperations.SelectedValue);
    }
    //load your combo again
    if(cbSelectedValue != null)
    cmbOperations.SelectedValue = cbSelectedValue.ToString();
    }
    

    There may be small syntax errors since I didn’t used VS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview with a DataTemplate that has a ComboBox. I want the
I want to have a select-only ComboBox that provides a list of items for
I have a radajaxpanel that is populated with the selected item from a combobox
I have a ComboBox that has its ItemsSource bound to a static List<CustomSettings> of
I have a ComboBox that I set up like this: this.cmbCustomerJob.DisplayMember = display; this.cmbCustomerJob.AutoCompleteMode
I have a Flex ComboBox that gets populated by a dataprovider all is well...
I have a combobox on my form that is bound to a generic list
I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items
I have the following table structure: I'm trying to populate a combobox of all
I have a situation where I need to access an object that has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.