• C#三级treenode搜索源码


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


    namespace ICD_search
    {
        public partial class UserControl1 : UserControl
        {
            private OleDbCommand Cmd;
            private OleDbDataReader Dr;
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Environment.CurrentDirectory + "\\icd-full.mdb";
            private OleDbConnection Conn;

            public UserControl1()
            {
                InitializeComponent();
            }

            private void UserControl1_Load(object sender, EventArgs e)
            {

                Conn = new OleDbConnection(strConn);
                this.Conn.Open();
                Cmd = Conn.CreateCommand();
                Cmd.CommandText = "select * from icdcode where icdcode like '___'";
                Dr = Cmd.ExecuteReader();


                while (Dr.Read())
                {

                    treeView1.Nodes.Add(Dr.GetString(1) + Dr.GetString(2));

                }

                Dr.Close();
                //从数据库中读取数据,通过递归生成树。


            }
            private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
            {


                if (textBox1.Text.Length == 3)//暂时只显示二级结点
                {
                    if (e.Node.Nodes.Count == 0 && e.Node.Level != 2)//是否展开树节点的判断
               {
                        string Sxuanzhong = treeView1.SelectedNode.Text.ToString().Substring(0, 3);
                        Cmd.CommandText = "select * from icdcode where icdcode like '" + Sxuanzhong + "._'";
                        Dr = Cmd.ExecuteReader();


                        while (Dr.Read())
                        {
                            e.Node.Nodes.Add(Dr.GetString(1) + Dr.GetString(2));

                        }
                        Dr.Close();
                    }
                       
                   
                }

                else
                {
                    if (e.Node.Nodes.Count == 0&&e.Node.Level != 2)//显示三级结点
          {
                        string Sxuanzhong = treeView1.SelectedNode.Text.ToString().Substring(0, 5);
                        Cmd.CommandText = "select * from icdcode where icdcode like '" + Sxuanzhong + "%'";
                        Dr = Cmd.ExecuteReader();
                        while (Dr.Read())
                        {
                            e.Node.Nodes.Add(Dr.GetString(1) + Dr.GetString(2));

                        }
                        Dr.Close();
                    }
                }


               
            }
            void  jiansuotestbox1()
            {
                int intlengthString = treeView1.SelectedNode.Text.ToString().Length;
                string Sxuanzhong=treeView1.SelectedNode.Text.ToString();
                char[] Cshuzu = Sxuanzhong.ToCharArray();
                byte[] myArrayByte = System.Text.Encoding.ASCII.GetBytes(Cshuzu);
                for (int i = 0; i < Sxuanzhong.Length; i++)
                {
                    if ((48 <= myArrayByte[i] && myArrayByte[i] <= 57) || (65 <= myArrayByte[i] && myArrayByte[i] <= 90) || myArrayByte[i] == 46 || myArrayByte[i] == 43)
                        textBox1.Text += Cshuzu[i].ToString();
                }
              
            }
            void jiansuotestbox2()
            {
                int intlengthString = treeView1.SelectedNode.Text.ToString().Length;
                string Sxuanzhong = treeView1.SelectedNode.Text.ToString();
                char[] Cshuzu = Sxuanzhong.ToCharArray();
                byte[] myArrayByte = System.Text.Encoding.ASCII.GetBytes(Cshuzu);
                for (int i = 0; i < Sxuanzhong.Length; i++)
                {
                    if (!((48 <= myArrayByte[i] && myArrayByte[i] <= 57) || (65 <= myArrayByte[i] && myArrayByte[i] <= 90) || myArrayByte[i] == 46 || myArrayByte[i] == 43))
                        textBox2.Text += Cshuzu[i].ToString();
                }

            }
            private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
            {
                textBox1.Clear();
                jiansuotestbox1();
                textBox2.Clear();
                jiansuotestbox2();
            }

            private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
            {
            
            }
        }
    }

  • 相关阅读:
    softmax in pytorch
    python使用xlrd读取excel数据
    redis集群扩容(添加新节点)
    redis集群添加新节点
    重新创建redis集群的注意事项
    在三台服务器,搭建redis三主三从集群
    UI自动化测试工具Airtest/Poco
    单个机器部署redis集群模式(一键部署脚本)
    内置函数二
    内置函数一
  • 原文地址:https://www.cnblogs.com/yuerdongni/p/2198501.html
Copyright © 2020-2023  润新知