Board index » delphi » tstringlist object property

tstringlist object property

My app uses a combobox to allow the user to pick a vendor. I'd like to
use the objects property to store the companynumber associated with that
vendor.

        I have accomplished this with the following code:

ComboBox1.Items.AddObject(Copy(TBVendorName.Value,1,20),Pointer(TBVendorNO.Value));

        When the user selects an item in the combo control, I'd like to assign
the vendor number to the transaction file as follows:

        TBTransVendorNo.Value:=ComboBox1.Items.Objects[ComboBox1.Itemindex];

        However, this assignment won't compile. It produces an error of
Incompatible integer/TObject. How can I accomplish this assignment ???

        Is there a better method to accomplish this task ??? Screen real estate
is at a premium so I used a drop combo box control.

        Thank you for your help.

Neil Huhta

 

Re:tstringlist object property


Try:

TBTransVendorNo.Value :=
  Integer( ComboBox1.Items.Objects[ComboBox1.Itemindex] );

Integer() is a cast.  You need to cast the object, which is of TObject
type, to an integer type.

--
Chris Cleveland
Genesee Development Group, Inc.
2000 North Racine Avenue, Suite 4100
Chicago, Illinois  60614
773.528.1700 voice, 773.528.8862 fax
http://genesee.net
cclevel...@genesee.net

Re:tstringlist object property


Neil,

Just cast back to a LongInt as follows ...

TBTransVendorNo.Value:=LongInt(ComboBox1.Items.Objects[ComboBox1.Itemindex]);

HTH,
Carl.

Quote
nhuhta wrote:

---8<---
>         TBTransVendorNo.Value:=ComboBox1.Items.Objects[ComboBox1.Itemindex];

>         However, this assignment won't compile. It produces an error of
> Incompatible integer/TObject. How can I accomplish this assignment ???

---8<---

Quote
> Neil Huhta

--
Please remove 'no__junk' from the return address to Email
me.

Other Threads