惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
T
Threat Research - Cisco Blogs
V
Vulnerabilities – Threatpost
T
Tor Project blog
T
Troy Hunt's Blog
C
CERT Recently Published Vulnerability Notes
C
Cisco Blogs
W
WeLiveSecurity
Cloudbric
Cloudbric
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
爱范儿
爱范儿
Google Online Security Blog
Google Online Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Martin Fowler
Martin Fowler
Cisco Talos Blog
Cisco Talos Blog
F
Full Disclosure
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
腾讯CDC
L
LangChain Blog
L
LINUX DO - 热门话题
H
Help Net Security
S
Schneier on Security
N
Netflix TechBlog - Medium
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
Spread Privacy
Spread Privacy
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
P
Privacy International News Feed
P
Privacy & Cybersecurity Law Blog
Cyberwarzone
Cyberwarzone
A
About on SuperTechFans
NISL@THU
NISL@THU
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
雷峰网
雷峰网
AWS News Blog
AWS News Blog
V2EX - 技术
V2EX - 技术

博客园 - RichardChoi

C#农历组件 - 修正版 - RichardChoi C#应用程序控制Excel工作簿操作-基本 C#应用程序控制Word文档操作-基本 对System Analysis and Design的课程设计的一些总结 同学Tomholmes对SAD课程设计的需求分析 System Analysis & Design 课程设计题目(英文) Visual Paradigm试用 - 不错的UML建模和代码生成工具 关于UML建模工具和项目管理工具的问题 NOW VS2005 Beta2 is really on installation process 对于Software Architecture和System Analysis比较的看法 SSITE发放VS2005 Beta2 杂篇(一) 突然醒悟 - 两年前的文章 NETCAFE - 两年前写的 等待.... VS2005 Beta2 VS2005 Beta2新信息 Now Installing VS2005 Beta2 VS2005 Beta2 is coming! 求System Analysis and Design的学习电子书和相关资料
C# SuperCombox组件
RichardChoi · 2005-05-22 · via 博客园 - RichardChoi

缓存内容,根据输入筛选结果

  1using System;
  2using System.Collections;
  3using System.ComponentModel;
  4using System.Drawing;
  5using System.Data;
  6using System.Windows.Forms;
  7
  8namespace NetBee.Infrastructure
  9{
 10    /// <summary>
 11    /// SuperComboBox 的摘要说明。
 12    /// </summary>

 13    public class SuperComboBox : System.Windows.Forms.ComboBox
 14    {
 15        /// <summary> 
 16        /// 必需的设计器变量。
 17        /// </summary>

 18        private System.ComponentModel.Container components = null;
 19
 20        private ArrayList _items=new ArrayList();
 21        private string cache;
 22
 23        public SuperComboBox()
 24        {
 25            // 该调用是 Windows.Forms 窗体设计器所必需的。
 26            InitializeComponent();
 27
 28            // TODO: 在 InitializeComponent 调用后添加任何初始化
 29        }

 30
 31        public void AddItemIn()
 32        {
 33            if(this._items.Count>0)
 34            {
 35                if(!this._items.Contains(this.Text) && this.Text!="")
 36                {
 37                    this._items.Add(this.Text);
 38                }

 39            }

 40            else
 41            {
 42                if(this.Text!="")
 43                {
 44                    this._items.Add(this.Text);
 45                }

 46            }

 47        }

 48
 49        public int GetItemsCount()
 50        {
 51            return this._items.Count;
 52        }

 53
 54        /// <summary> 
 55        /// 清理所有正在使用的资源。
 56        /// </summary>

 57        protected override void Dispose( bool disposing )
 58        {
 59            if( disposing )
 60            {
 61                if(components != null)
 62                {
 63                    components.Dispose();
 64                }

 65            }

 66            base.Dispose( disposing );
 67        }

 68
 69        #region 组件设计器生成的代码
 70        /// <summary> 
 71        /// 设计器支持所需的方法 - 不要使用代码编辑器 
 72        /// 修改此方法的内容。
 73        /// </summary>

 74        private void InitializeComponent()
 75        {
 76            // 
 77            // SuperComboBox
 78            // 
 79            this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SuperComboBox_KeyPress);
 80            this.TextChanged += new System.EventHandler(this.SuperComboBox_TextChanged);
 81
 82        }

 83        #endregion

 84
 85        private void SuperComboBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 86        {
 87            if(e.KeyChar=='\r')
 88            {
 89                this.DroppedDown=false;
 90                this.Text=this.cache;
 91                //this.DoSearch();
 92            }

 93
 94            if(char.IsControl(e.KeyChar))
 95            {
 96                if(e.KeyChar=='\b')
 97                {
 98                    this.DroppedDown=false;
 99                    this.Text=this.cache;
100                }

101            }

102        }

103
104        public void ShowList()
105        {
106            this.DroppedDown=true;
107        }

108
109        public void HideList()
110        {
111            this.DroppedDown=false;
112        }

113
114        public ArrayList GetFilteredList()
115        {
116            this.Items.Clear();
117
118            ArrayList newArrayList=new ArrayList();
119            newArrayList.Clear();
120            foreach(string str in this._items)
121            {
122                if(str.Length>0)
123                {
124                    if(str.IndexOf(this.Text)==0 && (!str.Equals(this.Text)))
125                    {
126                        newArrayList.Add(str);
127                    }

128                }

129            }

130            return newArrayList;
131        }

132        
133
134        private void SuperComboBox_TextChanged(object sender, System.EventArgs e)
135        {
136            this.cache=this.Text;
137            if(this.Text!="")
138            {
139                object[] al=this.GetFilteredList().ToArray();
140                if(al.Length>0)
141                {
142                    this.AddItemsCore(al);
143                    this.ShowList();
144                    if(this.cache!="")this.Text=this.cache;
145                    this.SelectionStart=this.Text.Length+1;
146                }

147                else
148                {
149                    if(this.DroppedDown==true)
150                    {
151                        this.HideList();
152                        this.Focus();
153                        this.SelectionStart=this.cache.Length;
154                    }

155                    else
156                    {
157                        this.SelectionStart=this.Text.Length+1;
158                    }

159                }
                    
160            }

161            
162        }

163    }

164}

165


Posted on 2005-05-22 22:05  RichardChoi  阅读(642)  评论(0)    收藏  举报