Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a combobox named (Merchant) ... and a checkbox(Non merchant) as well. I need to load the merchant name from the database when the check box is unchecked. And i need to load the name of non merchant when non merchant checkbox is checked?? can anyone help how to do so!
Posted
Comments
Sergey Alexandrovich Kryukov 23-Feb-14 14:06pm    
When you are asking about "CheckBox" or "ComboBox", the question is: which one? Full type names, please.
As you did not specify what you are talking about, the answers you already received may or may not be applicable.
—SA

Not difficult to do.

When the user selects merchant, popupate the merchant dropdown and hide the other dropwdown.
When the user loads non-merchant. load the other dropdown.
 
Share this answer
 
Assuming the collections of names of merchants, and non-merchants, in the database that you wish the user to have access to during a session remain fixed, I'd seek to minimize loading the ComboBoxes from the database.

I suggest you consider creating two ComboBoxes, one for merchants, one for non-merchants: make them the same size, and set their locations to be the same, and load their contents from the database once.

Then, in the CheckBox.CheckedChanges Event Handler, something like this:
C#
private void cbxSelectNonMerchant_CheckedChanged(object sender, EventArgs e)
{
    if (cbxSelectNonMerchant.CheckState == CheckState.Checked)
    {
        cmbNonMerchant.Visible = true;
        cmbMerchant.Visible = false;
    }
    else
    {
        cmbMerchant.Visible = true;
        cmbNonMerchant.Visible = false;
    }
}
This assumes that you would start your application with the 'cbxSelectNonMerchant CheckBox.CheckState set to 'Unchecked, the 'cmbMerchant CombobBox visible, and 'cmbNonMerchant hidden.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900