private void Form1_Load(object sender, EventArgs e){ SqlDataAdapter da = new SqlDataAdapter(); SqlConnection con = new SqlConnection(@"Data Source=NEXTELL-0136367\SQLEXPRESS;Initial Catalog=SuperMarketDBV10;Integrated Security=true"); SqlCommand cmd = new SqlCommand(); da.SelectCommand = cmd; da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.CommandText = "MstSPGetProductCodes"; da.SelectCommand.Connection = con; da.SelectCommand.Parameters.Add("@PProdID", SqlDbType.Int, -1).Direction = ParameterDirection.Output; da.SelectCommand.Parameters.Add("@PProdCode", SqlDbType.Char, 6).Direction = ParameterDirection.Output; DataTable dt = new DataTable(); con.Open(); da.Fill(dt); con.Close(); cmbProdNumber.DataSource = dt; cmbProdNumber.DisplayMember = "PProdCode"; cmbProdNumber.ValueMember = "PProdCode"; }private void cmbProdNumber_SelectedIndexChanged(object sender, EventArgs e){ if (cmbProdNumber.Items.Count != 0) { if (cmbProdNumber.SelectedIndex != -1) { Console.WriteLine("Hello"); } } }