I have A Class which is used to add Values to Combobox(One is used for display and other as Hidden)
public class ComboBoxItem
{
string displayValue;
string hiddenValue;
//Constructor
public ComboBoxItem(string displayVal, string hiddenVal)
{
displayValue = displayVal;
hiddenValue = hiddenVal;
}
//Accessor
public string HiddenValue
{
get
{
return hiddenValue;
}
}
//Override ToString method
public override string ToString()
{
return displayValue;
}
Using this class i add Values to Combobox
cmbServerNo.Items.Add(new ComboBoxItem(strIPAddress, iConnectionID.ToString()));
But i want to restrict duplicate values i am using the below approach
foreach (KeyValuePair<int, Object> ikey in m_lstConnectionID)
{
if (!cmbServerNo.Items.Contains(strIPAddress))
{
cmbServerNo.Items.Add(new ComboBoxItem(strIPAddress, iConnectionID.ToString()));
}
}
But it Guess it Adds both strIpAddress and ConnectionID so when i check it contains it fails. How to resolve this problem ? Thanks