I have a method that is filling my combobox
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);
}
}
}
Also,I have a DropDownClosed event.It is supposed to get the value from combo,and based on that to fill textbox with the data from the same row.
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;
}
}
}
When I start my app, right values are in the combobox. But when I select a value that is in Cyrillic(example: фдгдфгд), textBox_TloI doesn't get any data. But when I select a value that is latinic, it works fine. The problem is in combobox value. Because, If I select something latin from combo, it will display Cyrillic in textbox. It just doesn't seem to get the right Cyrillic value for filtering from the combobox.
When you are setting the txt of the text box you may need set the culture info
string tlo = reader[2].ToString(CultureInfo.CurrentCulture);