C # text box prompt

Source: Internet
Author: User

I just wrote a small program to implement the automatic prompt function of the C # text box. I feel pretty good to share with you.

 

Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. Data. sqlclient;

Namespace text box smart prompt
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}

Private void form1_load (Object sender, eventargs E)
{
String STR = "";
// Sqlconnection conn = new sqlconnection ();
// Conn. connectionstring = "Server = 10.68.69.203, 81; database = cpudata; user id = sa; Password = 19790601 ";
// Conn. open ();
// Sqlcommand cmd = new sqlcommand ();
// Cmd. commandtext = "select user_china_name from user_info ";
// Cmd. Connection = conn;
// Sqldataadapter da = new sqldataadapter (CMD );
// Dataset DS = new dataset ();
// Da. Fill (DS );
// Foreach (datarow DR in DS. Tables [0]. Rows)
//{
// STR + = "," + Dr ["user_china_name"];
//}
// Conn. Close ();
// STR = Str. substring (1 );
// This. textbox1.autocompletecustomsource. addrange (Str. Split (','));
Autocompletestringcollection ACSC = new autocompletestringcollection ();
Sqlconnection conn = new sqlconnection ();
Conn. connectionstring = "Server = 10.68.69.203, 81; database = cpudata; user id = sa; Password = 19790601 ";
Conn. open ();
Sqlcommand cmd = new sqlcommand ();
Cmd. commandtext = "select user_china_name from user_info ";
Cmd. Connection = conn;
Sqldatareader DR = cmd. executereader ();
While (dr. Read ())
{
ACSC. Add (Dr [0]. tostring ());
}
Dr. Close ();
Conn. Close ();
This. textbox1.autocompletemode = system. Windows. Forms. autocompletemode. Suggest;
This. textbox1.autocompletesource = system. Windows. Forms. autocompletesource. customsource;
This. textbox1.autocompletecustomsource = ACSC;

}
}
}

 

 

 

 

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.