C # Fuzzy search of ComboBox is implemented under WinCE, which is very convenient

Source: Internet
Author: User

Private ComboBox ComboBoxCurrent = new ComboBox (); private ListView ListViewCurrent = new ListView (); private string strFlag = ""; private void P_DefinListViewPosition (Panel panelTemp) {System. drawing. point Location = new System. drawing. point (0, ComboBoxCurrent. location. Y + ComboBoxCurrent. height); int Height = panelTemp. height-(ComboBoxCurrent. location. Y + ComboBoxCurrent. height)-30; if (Hei Ght <60) {Location = new Point (3, 50); Height = ComboBoxCurrent. location. y-50;} ListViewCurrent. location = new Point (3, Location. Y + panelTemp. location. y); ListViewCurrent. height = Height; ListViewCurrent. backColor = Color. lightBlue; // ListViewCurrent. items [0]. backColor = System. drawing. color. blue; // ListViewCurrent. items [0]. selected = true; this. listViewCurrent. visible = true;} private void P_ListView_ICItem_DoubleClick (object sender, EventArgs e) {ListViewCurrent. visible = false; if (ListViewCurrent. selectedIndices. count = 0) {return;} DataRow row = this. listViewCurrent. items [this. listViewCurrent. selectedIndices [0]. tag as DataRow; // strFlag ComboBoxCurrent. text = row ["FName"]. toString (); ComboBoxCurrent. tag = row; ComboBoxCurrent. focus ();} private void P_ListView_KeyDown (obje Ct sender, KeyEventArgs e) {if (e. keyCode = Keys. return) {P_ListView_ICItem_DoubleClick (sender, e); return;} if (e. keyCode = Keys. escape) {ListViewCurrent. visible = false; ComboBoxCurrent. focus (); return ;}} private void P_comboBox_KeyDown (object sender, KeyEventArgs e) {if (e. keyCode = Keys. return/* & listViewToControl. visible = false */) {string FNumber = ComboBoxCurrent. text. trim (); If (FNumber. Length <2) {labelStatus. Text = "the search condition is too short. Enter the query condition! "; Return;} string strSQL = @" select top 50t_ICItem.FItemID, t_ICItem.FNumber, t_ICItem.FName, t_ICItem.FModel, t1.FName as FUnitNamefrom t_ICItem Left Join t_MeasureUnit t1 on region = t1.FItemID where t_ICItem.FNumber like '% "+ FNumber + @" %' or t_ICItem.FName like '% "+ FNumber + @" % '"; dataTable tableTemp = new DataTable (); Cursor. current = Cursors. waitCursor; uint uiBeginTime = BaseWin3 2Function. GetTickCount (); // timing start if (true! = ClassWebService. WebGetDataSetFromService (strSQL, ref tableTemp) {labelStatus. Text = "the network times out. Please try again or check the network connection status! "+ CPublicParameters. P_ReturnTimePassed (uiBeginTime). ToString (); return; // if the network fails, return directly.} If (CPublicParameters. GetDataTableCountAll (tableTemp) <1) {labelStatus. Text = "no records found. Please perform the operation again! "+ CPublicParameters. p_ReturnTimePassed (uiBeginTime ). toString (); return;} labelStatus. text = "found records" + CPublicParameters. getDataTableCountAll (tableTemp ). toString () + @ ", please press the up or down key to select! "+ CPublicParameters. p_ReturnTimePassed (uiBeginTime ). toString (); CPublicParameters. datatableSort (ref tableTemp, "FNumber"); ListViewCurrent. items. clear (); ListViewCurrent. beginUpdate (); for (int I = 0; I <CPublicParameters. getDataTableCountAll (tableTemp); I ++) {DataRow dtRow = tableTemp. rows [I]; ListViewItem lv = new ListViewItem (new string [] {dtRow ["FNumber"]. toString (), dtRow ["FName"]. toString ()}); lv. tag = dtRow; ListViewCurrent. items. add (lv);} ListViewCurrent. columns [0]. text = "product code"; ListViewCurrent. columns [0]. width = 100; ListViewCurrent. columns [1]. text = "name"; ListViewCurrent. columns [1]. width = 140; this. listViewCurrent. endUpdate (); P_DefinListViewPosition (panel6); return;} if (e. keyCode = Keys. up & ListViewCurrent. visible = true) {ListViewCurrent. focus (); return;} if (e. keyCode = Keys. down & ListViewCurrent. visible = true) {ListViewCurrent. focus (); return;} if (e. keyCode = Keys. escape | e. keyCode = Keys. f14) & ListViewCurrent. visible = true) {ListViewCurrent. visible = false; return ;}} private void comboBox10_KeyDown (object sender, KeyEventArgs e) {ComboBoxCurrent = comboBox10; ListViewCurrent = listView1; P_comboBox_KeyDown (sender, e );} private void listviewincluitemactivate (object sender, EventArgs e) {P_ListView_ICItem_DoubleClick (sender, e);} private void listView1_KeyDown (object sender, KeyEventArgs e) {if (e. keyCode = Keys. return) {P_ListView_ICItem_DoubleClick (sender, e); return;} if (e. keyCode = Keys. escape) {ListViewCurrent. visible = false; ComboBoxCurrent. focus ();}}

This article is from the "Snow volcano" blog, please be sure to keep this source http://zw20045.blog.51cto.com/1135644/1290060

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.