public class ComboITem
{
private string sValue;
private string sDisplaytext;
ComboItem(string sv,string sd)
{
sValue=sv;
sDisplaytext=sd;
}
public ovveride string ToString()
{
return sDisplaytext;
}
public string Value
{
get
{
return sValue;
}
}
public staic bool u_SetItem(ComboBoxEdit combo,DataSet ds_source)
{
foreach(datarow dr in ds_source.tables[0].rows)
{
comboBoxEdit1.Properties.Items.add(new ComboITem(dr["displaycol"].tostring(),dr["valuecol"].tostring());
}
}
public static string u_GetItemvalue(ComboBoxEdit combo)
{
return ((ComboITem)combo.selectitem).Value;
}
public static bool u_SelectItem(ComboBoxEdit combo,string svalue)
{
int iIndex=0;
foreach(object obj in comboBoxEdit1.Properties.Items)
{
if(((ComboITem)obj).Value==svalue)
break;
iIndex++;
}
if(iIndex>=comboBoxEdit1.Properties.Items.Count)
---throw new exception() ---not found
else
comboBoxEdit1.Selectitem(iIndex)
return true;
}
}
I write this class for ComboboxEdit ,if you want to add item,
ComboITem.u_SetItem(comboBoxEdit1,ds_Binding)
if u want to get value for selected item:
string svalue=ComboITem.u_GetItemvalue(comboBoxEdit1);
if u want to display another item :
ComboITem.u_SelectItem(comboBoxEdit1,svalue);
this code not test,maybe u need to adjust it , if u have some question, i copy my code in my program to you.