First, the following comboBox1, ComboBox2, ComboBox3, the original three are empty,
Passing provinces in the database to ComboBox1
Second, in the Load method,
1. Query the values to be displayed in the ComboBox with the SQL command
2. Give the value to the DataTable
3. DisplayMember is the field in the database to be displayed: Org_short_name
Private voidTest_load (Objectsender, EventArgs e) { using(Sqliteconnection con =Newsqliteconnection (Constants.data_source)) {con. Open (); using(Sqlitecommand cmd =NewSqlitecommand ()) {cmd. Connection=con; Cmd.commandtext=string. Format ("Select T.org_short_name from sys_orgtable t"); introws =cmd. ExecuteNonQuery (); Sqlitedataadapter SDA=Newsqlitedataadapter (CMD); DataTable DT=NewDataTable (); Sda. Fill (DT); Combobox1.datasource=DT; Combobox1.displaymember="Org_short_name"; } } }
Iii. Results
Reference:
Https://zhidao.baidu.com/question/242563101.html?qbl=relate_question_2&word=c%20combobox%BC%D3%D4%D8%CA%FD %be%dd&skiptype=2
c#winfor realization of displaying database information on a ComboBox