组合框A到组合框B过滤起始字符从组合框A到组合框B匹配 [英] Combo box A to combo box B filtering starting characters match from Combo Box A to Combo Box B

查看:64
本文介绍了组合框A到组合框B过滤起始字符从组合框A到组合框B匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



ComboBoxA更改事件,通过从两个不同的表中加载字母来显示comboboxB值过滤器。



请帮帮我。



table1

DigitalCode

1234567890

2345678901

3456789012

4567890123



table2

dgGrp
12

23

3456

456



comboboxA comboboxB



1234567890 12

2345678901 23

3456789012 3456

4567890123 456

Hi All,

ComboBoxA change event to display comboboxB values filter by starting letters loading from two different tables.

Pls help me.

table1
DigitalCode
1234567890
2345678901
3456789012
4567890123

table2
dgGrp
12
23
3456
456

comboboxA comboboxB

1234567890 12
2345678901 23
3456789012 3456
4567890123 456

推荐答案

好吧,从我可以推断出你想做的事情我会使用以下内容:



Well, from what I can deduce you wanna do I would use the following:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private string[] table2 = new string[] { "12", "23", "3456", "456" };

        private void comboBoxA_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Find filter char
            char selectedChar = comboBoxA.Text[0];

            // Clear combo box
            comboBoxB.SelectedIndex = -1;
            comboBoxB.Items.Clear();

            // Repopulate by selected char
            for (int i = 0; i < table2.Length; i++)
            {
                if (table2[i][0] == selectedChar)
                {
                    comboBoxB.Items.Add(table2[i]);
                }
            }
        }
    }
}


这篇关于组合框A到组合框B过滤起始字符从组合框A到组合框B匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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