C # problems with the ComboBox droppeddown attribute

Source: Internet
Author: User

Function Description: assigns a value to ComboBox during initialization and then queries the database by entering the value. The function is similar to the Google search function.

If it is directly bound, dynamic data changes will report "Memory Corruption" information, so there is no binding here

Problems: 1. When a keyword is entered, the input order is in reverse order.

2. The mouse pointer is concealed by the form

3. After Entering the keyword, You need to click the content twice when the drop-down box automatically pops up.

4. After the drop-down list is displayed, you cannot use the keyboard up or down key to select

Code:

Private void combobox1_textchanged (Object sender, eventargs e) <br/>{< br/> try <br/>{< br/> This. combobox1.textchanged-= new system. eventhandler (this. combobox1_textchanged); <br/> combobox1.items. clear (); <br/> string text = This. combobox1.text; <br/> dataset = geturiresultinfo (text); </P> <p> // If (this. combobox1.text! = "" & This. combobox1.text! = "") <Br/> // {<br/> // combobox1.datasource = NULL; <br/>///} <br/> // combobox1.datasource = dataset. tables [0]; <br/> // combobox1.displaymember = "content"; <br/> // combobox1.valuemember = "seqno"; <br/> // combobox1.selectedindex =-1; </P> <p> for (INT I = 0; I <dataset. tables [0]. rows. count; I ++) <br/>{< br/> This. combobox1.items. add (Dataset. tables [0]. rows [I] ["content"]); <br/>}</P> <p> combobox1.droppeddown = true; </P> <p> combobox1.text = text; <br/> combobox1.selectionstart = combobox1.text. length; <br/> // display the mouse pointer <br/> system. windows. forms. cursor. current = system. windows. forms. cursors. ibeam; <br/> // keep the mouse pointer shape <br/> cursor = system. windows. forms. cursors. default; </P> <p> // cursor. show (); <br/> // cursor. position = new point (200,200); <br/> // cursor. position = new point (cursor. position. x, cursor. position. y); </P> <p> This. combobox1.textchanged + = new system. eventhandler (this. combobox#textchanged); <br/>}< br/> catch (exception ex) <br/>{< br/> console. writeline (ex. message); <br/> // applogger. logerrexception ("frmprint. CS // frmprint: loadurirpt ", ex); <br/>}< br/> finally {}< br/>}

 

Problems 1, 2, 3, and 4 are resolved.

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.