zoukankan      html  css  js  c++  java
  • 为WinForm combox控件增加自动完成功能

    http://hi.baidu.com/softwyy/blog/item/07ca0af679b7822a730eecbc.html

    private void toolStripButton3_Click(object sender, EventArgs e)
            {
                
    if (CanHistoryKey == true)              //让用户自己设置是否愿意使用自动完成的功能
                {
                     AutoCompleteStringCollection auto 
    = new AutoCompleteStringCollection();//定义并实例化AutoCompleteStringCollection类
                    if (MyLib.Properties.Settings.Default.HistoryKey != null)
                         auto 
    = MyLib.Properties.Settings.Default.HistoryKey;//设置时HistoryKey的值是为null的,所以不为空时我们需要加载旧的历史关键字
                     auto.Add(toolStripTextBox1.Text.Trim());                //添加新的历史关键字
                     MyLib.Properties.Settings.Default.HistoryKey = auto;    //将历史关键字进行更新(不过并没有保存)
                     toolStripTextBox1.AutoCompleteCustomSource = auto;   //立刻为控件添加新的历史关键字
                 }
             }


    //--------------------------------------------
    private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
            {
                 MyLib.Properties.Settings.Default.Save(); 
             }

    //--------------------------------------------
    private void 清空历史记录ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                 MyLib.Properties.Settings.Default.HistoryKey 
    = null;
                 toolStripTextBox1.AutoCompleteCustomSource 
    = null;
             }
  • 相关阅读:
    tcp/ip--百度百科
    Web service--百度百科
    .NET--百度百科
    ibatis--百度百科
    Struts2--百度百科
    spring--百度百科
    从头认识Spring-1.15 对SpEl的值的操作(1)-数值运算
    performSelector 方法的自己主动俘获特性
    图解WinHex使用入门
    LINQ使用与并行
  • 原文地址:https://www.cnblogs.com/wucg/p/1771424.html
Copyright © 2011-2022 走看看