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
Loading


Pankil BhattRank #2,947 · 489 reputationPosted Apr 16, 2015, 3:55 AM EDT
please comboBox binding values. it's shows null value...
priyanka bhatnagar44 reputationPosted Apr 16, 2015, 8:55 PM EDT
Akhil GargRank #772 · 3K reputationPosted Apr 17, 2015, 9:28 AM EDT
priyanka bhatnagar44 reputationPosted Apr 19, 2015, 10:58 PM EDT
priyanka bhatnagar44 reputationPosted Apr 19, 2015, 10:58 PM EDT
Akhil GargRank #772 · 3K reputationPosted Apr 20, 2015, 12:48 AM EDT
Vikram AgrawalRank #4,713 · 329 reputationPosted Apr 20, 2015, 1:19 AM EDT
Hi Priyanka,
use SelectedText Property of combobox instead of SelectedItem and then compare it with combobox2
thanks