窗口形式的“自动完成"文本框 [英] AutoComplete Text Box in wndows form

查看:52
本文介绍了窗口形式的“自动完成"文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我想做一个字典类的Windows应用程序.我有一个庞大的数据库.现在,在Windows窗体中,我有一个文本框,用户可以在其中输入要搜索的单词.我很困惑如何实现它.我在Web应用程序中做了相同的操作,但是使用了ajax工具包.它是AutoCompleteTextBox扩展程序.

在Windows应用程序中我们如何实现呢???有什么建议吗?

在此先感谢..

Dear all,

I want to make a dictionary kind of windows application. I have a huge database with me. Now in my windows form I have a text box where user enter the word to search. I am confused how to achieve it. I did it the same in web application but by using ajax toolkit. it was AutoCompleteTextBox extender.

In windows application how we can achieve it??? Any suggestions please???

Thanks in advance..

推荐答案

用作
public partial class empassetReport : Form
   {
       AutoCompleteStringCollection namesCollection =new AutoCompleteStringCollection();
       public static bool isOpen = false;

       public empassetReport()
       {
           InitializeComponent();
       }

       private void empassetReport_Load(object sender, EventArgs e)
       {
           isOpen = true;

           this.Location = new Point(150, 100);
           SqlDataReader dReader;
           SqlConnection conn =Db.GetConnection();
           //conn.ConnectionString = strConnection;
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandType = CommandType.Text;
           cmd.CommandText =
           "Select distinct(name) from empbirth" +
           " order by name asc";
           //conn.Open();
           dReader = cmd.ExecuteReader();
           if (dReader.HasRows == true)
           {
               while (dReader.Read())
                   namesCollection.Add(dReader["name"].ToString());

           }
           else
           {
               MessageBox.Show("Data not found");
           }
           dReader.Close();

           textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
           textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
           textBox1.AutoCompleteCustomSource = namesCollection;


       }


您还可以看到
winforms-autocomplete-textbox


you can see also
winforms-autocomplete-textbox


请参考这些过去的问题:

需要一个支持Intellisense功能的文本框 [
Refer to these past question:

Needs a text box that support Intellisense feature[^]


在这里查看这些URL,您将获得完整的示例:
http://www.dotnetfunda.com/articles/article225.aspx [ http://www.csharpaspnetarticles.com/2009/01/winforms-autocomplete- textbox-using-c.html [ ^ ]
have a look these urls here you will get complete examples:
http://www.dotnetfunda.com/articles/article225.aspx[^]
http://www.csharpaspnetarticles.com/2009/01/winforms-autocomplete-textbox-using-c.html[^]


这篇关于窗口形式的“自动完成"文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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