我有一种方法来填充我的组合框
using (SqlConnection conn = new SqlConnection(ConString))
{
// DO REMEMBER TO OPEN THE CONNECTION!!!
conn.Open();
// Connection Established
SqlCommand command = new SqlCommand("SELECT * FROM monitoring", conn);
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string item = reader[11].ToString();
comboBoxPretraga.Items.Add(item);
}
}
}另外,我有一个DropDownClosed event.It,它应该从组合体中获取值,并在此基础上用同一行的数据填充textbox。
using (SqlConnection conn = new SqlConnection(ConString))
{
conn.Open();
// Connection Established
SqlCommand command = new SqlCommand("SELECT * FROM monitoring monitoring where konzervator_ime_prezime='" + comboBoxPretraga.Text + "'", conn);
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string tlo = reader[2].ToString();
textBox_TloI.Text = tlo;
}
}
}当我启动我的应用程序时,正确的值在组合框中。但是,当我选择一个以西里尔语表示的值(例如:фдгдфгд)时,фдгдфгд不会得到任何数据。但是当我选择一个拉丁值时,它工作得很好。问题在于组合框的价值。因为,如果我从组合体中选择拉丁文,它将在文本框中显示西里尔字母。它只是似乎没有得到正确的西里尔值过滤从组合框。
发布于 2016-07-26 13:15:56
设置文本框的txt时,可能需要设置区域性信息。
string tlo = reader[2].ToString(CultureInfo.CurrentCulture);https://stackoverflow.com/questions/38590582
复制相似问题