Say I had a ComboBox with these values:
Black
Red
Blue
And I have Red
currently selected. If the user then hits backspace and
There is no inbuilt function to get the index for given value but you can find the index through this function.
Usage:
int cmbindex = CmbIdxFindByValue("YourValue", cmbYourComboBox);
Function:
private int CmbIdxFindByValue(string text, ComboBox cmbCd)
{
int c = 0; ;
DataTable dtx = (DataTable)cmbCd.DataSource;
if (dtx != null)
{
foreach (DataRow dx in dtx.Rows)
{
if (dx[cmbCd.ValueMember.ToString()].ToString() == text)
return c;
c++;
}
return -1;
}else
return -1;
}