Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread TButtonComboBox confused
Fri, Aug 21 2020 10:01 PMPermanent Link

KimHJ

Comca Systems, Inc

I'm confussed about the TButtonComboBox.

I have this Dataset.

City                    Country
------------------------------------
Miami                 USA
Copenhagen      Denmark
Stockholm          Sweden

I load a database field into a TButtonComboBox in Items.Add
I link the Dataset and the field to the TButtonComboBox.

If I select an item from the drop down I can see the Field I selected by selecting the column from the Dataset like this in the OnChange event .
ShowMessage(Dataset.Columns['City'].AsString);

But I can not read any other fields from the same record, it will always show me the value from the first record (item).

ShowMessage(Dataset.Columns['Country'].AsString);

Any city selected will give me USA


Is this how it is?

Thanks,
Kim
Mon, Aug 24 2020 8:57 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

Kim,

I have not been able to get TButtonComboBox to work as I expected. I use TEditCombBox and populate the drop down list.

Richard

CREATE TABLE "StockTypes"
(
"ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 1) NOT NULL,
"StockCategory" VARCHAR(3) COLLATE "ANSI_CI" NOT NULL,
"FieldName" VARCHAR(16) COLLATE "ANSI_CI" NOT NULL,
"Option" VARCHAR(32) COLLATE "ANSI_CI" NOT NULL,
CONSTRAINT "syPrimaryIND" PRIMARY KEY ("ID")
)

"ID","StockCategory","FieldName","Option"
21,"PNS","Type","Regular S.A.L.T."
22,"PNS","Type","Regular Dry"
23,"PNS","Type","Master"
28,"RLS","Type","Carrier"
29,"RLS","Type","Bottom"
30,"RLS","Flange","Single"
31,"RLS","Flange","Double"
120,"994","Condition","Secondhand"
121,"994","Condition","New"
1000,"994","Condition","Repaired"

StockOptionsForCondition
------------------------

SELECT ID, FieldName, Option
 FROM StockTypes
 WHERE
   StockCategory={StockCategory='994'}

procedure TfmTest11.fmTest11Show(Sender: TObject);
begin
 esStockOptionsForCategory.Params.Clear;
 esStockOptionsForCategory.Params.Add('StockCategory=' + QuotedStr('994'));
 DataBase.LoadRows(esStockOptionsForCategory);
 Database.LoadRows(aStockItem);
end;

// ==============================================================================

procedure TfmTest11.cbConditionDropDownShow(Sender: TObject);
begin
// Sender is the TEditCombBox that has a 2 letter prefix before the Column Name
 
  OriginalValue := TEditComboBox(Sender).Text;
  ValueForColumn := copy(TEditComboBox(Sender).Name, 3);
  SenderName := TEditComboBox(Sender).Name;

  TEditComboBox(Sender).Items.Clear;

  esStockOptionsForCategory.First;
  while not esStockOptionsForCategory.eof do
  begin
     if esStockOptionsForCategory.Columns['FieldName'].AsString = ValueForColumn
       then TEditComboBox(Sender).Items.Add(esStockOptionsForCategory.Columns['Option'].AsString);
     esStockOptionsForCategory.Next;
  end;
  TEditComboBox(Sender).Text := OriginalValue;
end;
Mon, Aug 24 2020 9:54 PMPermanent Link

KimHJ

Comca Systems, Inc

Richard Harding wrote:

>>I have not been able to get TButtonComboBox to work as I expected. I use TEditCombBox and populate the drop down list.<<

You add a ID to each item and then read that to find the item.
Then the ID shows in the drop down selection.
What you are saying is that none of the combobox works correctly.

Thanks,
Kim
Tue, Aug 25 2020 7:10 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

<< You add a ID to each item and then read that to find the item.
Then the ID shows in the drop down selection.
What you are saying is that none of the combobox works correctly.>>

TEditComboBox works as shown above but not TButtonComboBox.

Richard
Image