文本框自动查询信息,产生记忆性列表

        private void txtSNum_TextChanged(object sender, EventArgs e)  

       {            

    txtSName.Enabled = false;

            this.txtSNum.AutoCompleteSource = AutoCompleteSource.CustomSource;

            this.txtSNum.AutoCompleteMode = AutoCompleteMode.Suggest;

            string sqy = "select SNUM,sname from  xhs where SClass123='"+cobGrade123.Text+"'";

            DataSet ds = sServer.GetDataSet1(sqy);

            for (int i = 0; i < dy.Tables[0].Rows.Count; i++)  

           {

                this.txtSNum.AutoCompleteCustomSource.Add(ds.Tables[0].Rows[i][0].ToString() + "|" + ds.Tables[0].Rows[i][1].ToString());

            }

        }

 
posted @ 2014-07-17 21:02  "幸 福 。  阅读(135)  评论(0编辑  收藏  举报