• 可输入的模糊搜索ComBox控件


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace CommonControl
    {
        public partial class SC_ComBox : UserControl
        {
            public SC_ComBox()
            {
                InitializeComponent();
            }
            #region Properties
            private DataTable dt;
            public DataTable DT
            {
                get { return dt;}
                set { dt = value; }
            }
            private string displayMember;
            public string DisplayMember
            {
                get { return displayMember; }
                set { displayMember = value; }
            }
            private string valueMember;
            public string ValueMember
            {
                get { return valueMember; }
                set { valueMember = value; }
            }
            #endregion
            private void SC_ComBox_TextUpdate(object sender, EventArgs e)
            {
                CBload();
            }
            public void CBload()
            {
                string defaulttxt = this.comboBox1.Text;
                DataView dv = dt.DefaultView;
                if (!string.IsNullOrEmpty(this.comboBox1.Text))
                    dv.RowFilter = DisplayMember + " like '%" + this.comboBox1.Text + "%'";
                DataTable dtnew = dv.ToTable();
                this.comboBox1.DataSource = dtnew;
                this.comboBox1.DisplayMember = displayMember;
                this.comboBox1.ValueMember = valueMember;
                this.comboBox1.Text = defaulttxt;
                this.comboBox1.DroppedDown = true;
                this.comboBox1.SelectionStart = defaulttxt.Length;//光标位置在右边
            }
            private void comboBox1_MouseClick(object sender, MouseEventArgs e)
            {
                CBload();
            }
        }
    }
  • 相关阅读:
    Windows10内置Linux子系统安装及C++编程环境配置
    在iOS平台上使用gtest进行单元测试
    【转载】Android7.0以前和7.0以后开启闪光灯的方式
    C++11 move记录
    决策树
    生成MTLLibrary
    【转载】3D显示技术
    vector::insert和std::copy
    Visual Studio 2017 + CMake + CUDA
    词嵌入向量WordEmbedding
  • 原文地址:https://www.cnblogs.com/sulong/p/4900234.html
Copyright © 2020-2023  润新知