DBCombo or DbList with Index into Field 
Author Message
 DBCombo or DbList with Index into Field

    Does anyone have or know of a DBCombo or DBListbox component to
put/get its display value based on its index. ie DBCombo.Items[1] is the
word 'Australia'. If the user selects Australia, I would like the field
to be the value '1' not 'Australia'.This would be like having a DB of
Countries and having a DBLookUpCombo box with Display of Field2 but
KeyField of Field1.
    At present I do this manually OnPost or OnChange of PrimaryKey
value. But I will write a component if I'm not reinventing the wheel by
doing so.

Any Thoughts Welcome
Echo To Email if Possible As well please.

Davin Barrott



Wed, 18 Jun 1902 08:00:00 GMT  
 DBCombo or DbList with Index into Field

DGRadioGroup works the way you want:

Items contains the displayed values
Values contain the database values

If you have lots of values in you list, you could put the DBRadioGroup
in a scrollbox and size it (the DBRadioGroup) large enough to hold all
the values...

with DBRadiogroup do height:=canvas.textheight('X')*items.count;
{rough guess with extra room}

OR

var
 i, tall: integer;
begin
 tall:=0;
 with DBRadioGroup1 do
 begin
  for i:=0 to pred(items.count) do
inc(tall,canvas.textheight(items[i]));
  height:=tall;
 end;
end;

Place the DBRadiogroup in the upper left corner of the scrollbox.  DO
NOT align the DBRadioGroup to anything other than alNone.  If you use
more than one column (DBRadioGroup1.columns) in the DBRadioGroup, you'll
have to adjust the code for the tallest column (e.g. 7 items in 2
columns need to be sized for 4 rows).

Quote:

>     Does anyone have or know of a DBCombo or DBListbox component to
> put/get its display value based on its index. ie DBCombo.Items[1] is
> the
> word 'Australia'. If the user selects Australia, I would like the
> field
> to be the value '1' not 'Australia'.This would be like having a DB of
> Countries and having a DBLookUpCombo box with Display of Field2 but
> KeyField of Field1.
>     At present I do this manually OnPost or OnChange of PrimaryKey
> value. But I will write a component if I'm not reinventing the wheel
> by
> doing so.

> Any Thoughts Welcome
> Echo To Email if Possible As well please.

> Davin Barrott




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DBCombo & DBList boxes

2. Field Index Out of Range when trying to re-open a table with a different index

3. D1 DBList component problems?

4. Index Detail on Field other than link field

5. master field and index field.

6. DBCombo Initially Blank

7. PickList for DBCombo?

8. DBCombo informations

9. DBEdit to DBCombo

10. DBCombo Box Update

11. DBLookUpCombos vs DBCombos or Combos

12. d2:searching for special dbcombo

 

 
Powered by phpBB® Forum Software