My codes works fine but, when I make thread I got Cross-thread operation not valid when try to add item to ComboBox
. I tried this codes in backgroundworker
too but same error
new Thread(GetInfo).Start();
public void GetInfo()
{
while (true)
{
if (SellerControlGroup.Enabled)
{
SqlDataReader Type = new SqlCommand("select type from _Price where Service = 1", sqlCon.con).ExecuteReader();
while (Type.Read())
{
string type = Convert.ToString(Type["type"]);
ProgramType.Items.Add(type);
}
Type.Close();
}
}
}