I’m having a TComboBox component(comboxCountry) on my form.
And here’s the items inside the TComboBox.
Item 1 : ‘Singapore SG’
Item 2 : ‘India IND’
Item 3 : ‘Australia AUS’ and etc etc etc ..
When the combobox value is changed, i want the combboxCounty.Text to
only display the country code instead of the whole String in the items list.
For example, i want to only display ‘SG’ instead of ‘Singapore SG’ .. Here’s how i do
for cboxBankCategory OnChange function:
if comboxCountry.ItemIndex = 0 then
comboxCountry.Text := 'SG'
else if comboxCountry.ItemIndex = 1 then
comboxCountry.Text := 'IND'
else
comboxCountry.Text := 'AUS'
It seems correct, but it doesn’t works for me as the comboxCountry.Text still display
the whole country definition in the item list instead of only the country code, anything
wrong with my code anyone ?
Thanks.
Set the combobox style to
csOwnerDrawFixed, and in theonDrawItemevent put this:and clear the OnChange event.