这是我的代码,我也为每个文本框设置
autocomplete = collection,autocompletemode = append,autocompletesource = customsource。
但它只是在textbox24
和textbox22
中执行。有什么问题?
private void Form1_Load(object sender, EventArgs e)
{
radioButton1.Checked = true;
label19.Text = "00";
label18.Text = "00";
chExport.Checked = true;
chImport.Checked = false;
SenderText1.Enabled = false;
RecieverText1.Enabled = true;
ImportSum.Enabled = false;
SqlConnection Con = new SqlConnection("Data Source=mypro;InitialCatalog=pro1;Integrated Security=True");
Con.Open();
UpdateDataGrid();
SqlCommand cmd = new SqlCommand("SELECT PartName,Sender,Reciever,Address,Driver,CarType FROM office", Con);
SqlDataReader reader = cmd.ExecuteReader();
AutoCompleteStringCollection MyCollection1 = new AutoCompleteStringCollection();
AutoCompleteStringCollection MyCollection2 = new AutoCompleteStringCollection();
AutoCompleteStringCollection MyCollection3 = new AutoCompleteStringCollection();
AutoCompleteStringCollection MyCollection4 = new AutoCompleteStringCollection();
AutoCompleteStringCollection MyCollection5 = new AutoCompleteStringCollection();
AutoCompleteStringCollection MyCollection6 = new AutoCompleteStringCollection();
while (reader.Read())
{
MyCollection1.Add(reader.GetString(0));
MyCollection2.Add(reader.GetString(1));
MyCollection3.Add(reader.GetString(2));
MyCollection4.Add(reader.GetString(3));
MyCollection5.Add(reader.GetString(4));
MyCollection6.Add(reader.GetString(5));
}
textBox3.AutoCompleteCustomSource = MyCollection1;
PartName1.AutoCompleteCustomSource = MyCollection1;
textBox5.AutoCompleteCustomSource = MyCollection2;
SenderText1.AutoCompleteCustomSource = MyCollection2;
textBox6.AutoCompleteCustomSource = MyCollection3;
RecieverText1.AutoCompleteCustomSource = MyCollection3;
textBox9.AutoCompleteCustomSource = MyCollection4;
textBox24.AutoCompleteCustomSource = MyCollection5;
textBox22.AutoCompleteCustomSource = MyCollection6;
Con.Close();
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1;
}