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

推荐订阅源

N
News and Events Feed by Topic
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
Latest news
Latest news
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
K
Kaspersky official blog
Forbes - Security
Forbes - Security
T
Tenable Blog
The Last Watchdog
The Last Watchdog
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
Project Zero
Project Zero
O
OpenAI News
L
LINUX DO - 热门话题
P
Privacy International News Feed
月光博客
月光博客
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
量子位
博客园 - 【当耐特】
罗磊的独立博客
T
Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Cisco Blogs
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
N
News | PayPal Newsroom
腾讯CDC
Security Latest
Security Latest
J
Java Code Geeks
L
LINUX DO - 最新话题
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
D
Docker
Spread Privacy
Spread Privacy
S
Security @ Cisco Blogs
A
Arctic Wolf
H
Hacker News: Front Page
Help Net Security
Help Net Security
Recorded Future
Recorded Future
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)    收藏  举报