问题描述
嗨frds,
我有S.No喜欢A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12就像那样。当我输入A时它应用自动完成选项它显示如A1,A10,A11,A12,A2,A3,A4,A5,A6,A7,A8,A9但我想要A1,A2,A3,A4,A5,A6, A7,A8,A9,A10,A11,A12这种格式我怎么能这样做。在此先感谢。
我尝试过:
textBox1。 AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection DataCollection50 = new AutoCompleteStringCollection();
getData50(DataCollection50) ;
textBox1.AutoCompleteCustomSource = DataCollection50;
private void getData50(AutoCompleteStringCollection dataCollection50)
{
string connetionString1 = null;
SqlConnection connection1;
SqlCommand command1;
SqlDataAdapter adapter1 = new SqlDataAdapter();
DataSet ds1 = new DataSet();
string sql1 =SELECT DISTINCT [S_No] FROM [Table1 ],Con;
connection1 = new SqlConnection(connetionString1);
try
{
connection1.Open();
command1 = new SqlCommand(sql1,connection1);
adapter1.SelectCommand = command1;
adapter1.Fill(ds1);
adapter1.Dispose() ;
command1.Dispose();
connection1.Close();
foreach(ds1.Tables [0]中的DataRow行.Rows )
{
dataCollection50.Add(row [0] .ToString());
}
}
catch
{
MessageBox.Show(无法打开连接! );
}
}
Hi frds,
I have S.No like A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12 Like that. I Apply autocomplete option when i type A it display like A1,A10,A11,A12,A2,A3,A4,A5,A6,A7,A8,A9 but I want in A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12 this format how can i do this. Thanks in advance.
What I have tried:
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection DataCollection50 = new AutoCompleteStringCollection();
getData50(DataCollection50);
textBox1.AutoCompleteCustomSource = DataCollection50;
private void getData50(AutoCompleteStringCollection dataCollection50)
{
string connetionString1 = null;
SqlConnection connection1;
SqlCommand command1;
SqlDataAdapter adapter1 = new SqlDataAdapter();
DataSet ds1 = new DataSet();
string sql1 = "SELECT DISTINCT [S_No] FROM [Table1]",Con;
connection1 = new SqlConnection(connetionString1);
try
{
connection1.Open();
command1 = new SqlCommand(sql1, connection1);
adapter1.SelectCommand = command1;
adapter1.Fill(ds1);
adapter1.Dispose();
command1.Dispose();
connection1.Close();
foreach (DataRow row in ds1.Tables[0].Rows)
{
dataCollection50.Add(row[0].ToString());
}
}
catch
{
MessageBox.Show("Can not open connection ! ");
}
}
这篇关于如何设置自动完成的升序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!