Getting error in my c# code please help
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
comboBox2.Text = "";
if (comboBox1.SelectedIndex != -1)
{
var source = new AutoCompleteStringCollection();
string[] sValues = new string[0];
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
if (!comboBox2.Items.Contains(dr.Cells[comboBox1.SelectedItem.ToString()].Value))
{
comboBox2.Items.Add(dr.Cells[comboBox1.SelectedItem.ToString()].Value);
Array.Resize(ref sValues, sValues.Length + 1);
sValues[sValues.Length - 1] = Convert.ToString(dr.Cells[comboBox1.SelectedItem.ToString()].Value);
}
}
source.AddRange(sValues);
comboBox2.AutoCompleteCustomSource = source;
}
}
Error is Value cannot be null. Parameter name: value