The TwwDBComboBox requires that the display value be unique. It does not support the mode you are using. I suggest using the TwwDBLookupCombo instead for this as it is more capable in this situation. If you don't want to have to create a physical dataset, you don't have to as you can create an in-memory dataset for this. For instance drop in a TwwDBLookupCombo and TwwClientDataSet and set the fielddefs to the fieldnames that you want, or copy the following text to the clipboard and paste it into your form to create the in-memory dataset.
object ClientDataSet2: TClientDataSet
Active = True
Aggregates = <>
FieldDefs = <
item
Name = 'Description'
DataType = ftString
Size = 20
end
item
Name = 'Code'
DataType = ftInteger
end>
IndexDefs = <>
Params = <>
StoreDefs = True
Left = 296
Top = 88
Data = {
600000009619E0BD010000001800000002000000000003000000600014436C69
656E7444617461536574324669656C6431010049000000010005574944544802
000200140014436C69656E7444617461536574324669656C6432040001000000
00000000}
end
The set your lookupfield to code and lookuptable to your newly created clientdataset. Finally the only remaining step is to initialize the data in your form's OnShow event. For instance....
procedure TComboDemoForm.FormShow(Sender: TObject);
begin
clientdataset2.Insert;
clientdataset2.fieldbyname('description').AsString:= 'David';
clientdataset2.fieldbyname('code').AsString:= '12';
clientdataset2.Insert;
clientdataset2.fieldbyname('description').AsString:= 'David';
clientdataset2.fieldbyname('code').AsString:= '14';
clientdataset2.Post;
clientdataset2.Insert;
clientdataset2.fieldbyname('description').AsString:= 'Paul';
clientdataset2.fieldbyname('code').AsString:= '16';
clientdataset2.Post;
clientdataset2.Insert;
clientdataset2.fieldbyname('description').AsString:= 'John';
clientdataset2.fieldbyname('code').AsString:= '17';
clientdataset2.Post;
clientdataset2.Insert;
clientdataset2.fieldbyname('description').AsString:= 'Paul';
clientdataset2.fieldbyname('code').AsString:= '18';
clientdataset2.Post;
end;
-Roy