Board index » delphi » Tcombobox display and translate capabilities

Tcombobox display and translate capabilities

I am reading and modifying an ASCII text comma separated file.  I have
TEdits for most fields except for those where I want specific fields
entered and those entered fields translated to a code. For those I use
comboboxes.
I have a combobox (10 actually) that reads database items into the
items list using combobox.items.add(). I have two database fields,
LOOKUP and TRANSLATE (original huh?). I put the LOOKUP data into the
items list. The data entry people see the lookup in the list but I want
the translate field to get put into the ascii file file instead of the
lookup field.  Is there an efficient way to do this??  The program
already starts slow because I add the items list to 10 comboboxes.  I
can do all this easily if I were adding to a database record but I don't
want to have to start adding to a datarecord and then unloading that
datarecord to a text file.  Any and all ideas are gratefully
appreciated!
 

Re:Tcombobox display and translate capabilities


In article <3A639565.E8084...@nycap.rr.com>, Jim Blake <jbla...@nycap.rr.com>
writes:

Quote
>I am reading and modifying an ASCII text comma separated file.  I have
>TEdits for most fields except for those where I want specific fields
>entered and those entered fields translated to a code. For those I use
>comboboxes.
>I have a combobox (10 actually) that reads database items into the
>items list using combobox.items.add(). I have two database fields,
>LOOKUP and TRANSLATE (original huh?). I put the LOOKUP data into the
>items list.

Is this a separate table or are these fields in every record of the main table
(that being filled by the data entry users).

Quote
> The data entry people see the lookup in the list but I want
>the translate field to get put into the ascii file file instead of the
>lookup field.  Is there an efficient way to do this??

Is the conversion between LookUp and Translate the same for all TEdits.

Quote
>  The program
>already starts slow because I add the items list to 10 comboboxes.  I
>can do all this easily if I were adding to a database record but I don't
>want to have to start adding to a datarecord and then unloading that
>datarecord to a text file.  Any and all ideas are gratefully
>appreciated!

Does the conversion list ,or its contents, change.

Alan Lloyd
alangll...@aol.com

Re:Tcombobox display and translate capabilities


Something like:

type
  TForm1 = class(TForm)
    Table1: TTable;
    Table1LOOKUP: TStringField;
    Table1TRANSLATE: TStringField;
    ComboBox1: TComboBox;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    TranslateList: TStrings;
  public
    { Public declarations }
  end;

...

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Create translation list
  TranslateList := TStringList.Create;
  // Fill combobox and translation list
  Table1.Open;
  try
    while not Table1.EOF do
    begin
      ComboBox1.Items.Add(Table1.FieldByName('LOOKUP').AsString);
      TranslateList.Add(Table1.FieldByName('TRANSLATE').AsString);
    end;
  finally
    Table1.Close;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // Free translation list
  TranslateList.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  S: String;
begin
  // In case of Style = csDropDown
  i := ComboBox1.Items.IndexOf(ComboBox1.Text);
  // or in case of Style = csDropDownList
  i := ComboBox1.ItemIndex;

  // Use translation instead of lookup
  if (i >= 0) and (i < TranslateList.Count) then
    S := TranslateList[i]
  else
    S := '';
end;

"Jim Blake" <jbla...@nycap.rr.com> schreef in bericht
news:3A639565.E808449D@nycap.rr.com...

Quote
> I am reading and modifying an ASCII text comma separated file.  I have
> TEdits for most fields except for those where I want specific fields
> entered and those entered fields translated to a code. For those I use
> comboboxes.
> I have a combobox (10 actually) that reads database items into the
> items list using combobox.items.add(). I have two database fields,
> LOOKUP and TRANSLATE (original huh?). I put the LOOKUP data into the
> items list. The data entry people see the lookup in the list but I want
> the translate field to get put into the ascii file file instead of the
> lookup field.  Is there an efficient way to do this??  The program
> already starts slow because I add the items list to 10 comboboxes.  I
> can do all this easily if I were adding to a database record but I don't
> want to have to start adding to a datarecord and then unloading that
> datarecord to a text file.  Any and all ideas are gratefully
> appreciated!

Other Threads