Hi,
I have a combobox on a tab control the 2nd tab that does
not behave properly.
When I try to set the selectedindex by iterating
the items collection I get cmb.Items.Count = 0.
This is a custom funciotn to set the index
from a value code is below.
But if i put the same combobox directly on the form
it works fine.
Any ideas????
rotsey
public void FindByValue(string value, string columnname)
{
int aIndex;
DataRowView drv;
if (this.Name == "PayFrequency")
Console.WriteLine("");
ComboDebug.Instance.list.Add(this.Name + " ---- NumItems: " +
this.Items.Count);
for (aIndex = 0; aIndex < this.Items.Count; aIndex += 1)
{
try
{
drv = (DataRowView)this.Items[aIndex];
if (drv.Row[columnname].ToString() == value)
{
this.SelectedIndex = aIndex;
return;
}
}
catch (Exception)
{
if(this.Items[aIndex].ToString() == value)
{
this.SelectedIndex = aIndex;
return;
}
}
}
this.SelectedIndex = -1;
return;
//throw new Exception("Could not find value '" + value + "' in combobox " +
this.Name);
}