加载两个不同的组合框 [英] Loading two different combobox

查看:111
本文介绍了加载两个不同的组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为(商家)的组合框......以及一个复选框(非商家)。当取消选中复选框时,我需要从数据库加载商家名称。当我检查非商家复选框时,我需要加载非商家的名称?任何人都可以帮忙怎么做!

解决方案

不难做到。



当用户选择时商家,弹出商家下拉菜单并隐藏其他下拉菜单。

当用户加载非商家时。加载另一个下拉列表。


假设您希望用户在会话期间访问的数据库中的商家名称和非商家名称的集合保持固定,我会寻求最小化从数据库加载ComboBoxes。



我建议您考虑创建两个ComboBox,一个用于商家,一个用于非商家:使它们大小相同,并将它们的位置设置为相同,并且从数据库加载一次内容。



然后,在CheckBox.CheckedChanges事件处理程序中,如下所示:

  private   void  cbxSelectNonMerchant_CheckedChanged( object  sender,EventArgs e)
{
if (cbxSelectNonMerchant.CheckState == CheckState.Checked)
{
cmbNonMerchant.Visible = ;
cmbMerchant.Visible = false ;
}
else
{
cmbMerchant.Visible = true ;
cmbNonMerchant.Visible = false ;
}
}

这假设您将使用'cbxSelectNonMerchant CheckBox.CheckState设置为'未选中,'cmbMerchant CombobBox可见'和'cmbNonMerchant隐藏'来启动应用程序。 BLOCKQUOTE>

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!

解决方案

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.


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:

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.


这篇关于加载两个不同的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆