Can you only use a record type, it is just so much easier to read (and OO)
if you use a class instance instead.

E.g.

NewRec := TNewRec.Create;
NewRec := ...
Combo.Items.AddObject(NewRec);

...

Il_Provider := TNewRec(Combo.items.Objects[Combo.ItemIndex]).ID);

Yes you can use the dynamically allocated memory stuff with new and dispose
of course...

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of [EMAIL PROTECTED]
> Sent: Saturday, 7 October 2000 02:33
> To: Multiple recipients of list delphi
> Subject: [DUG]: AddObject in Combobox
>
>
> HI all.
>
> I am wanting to add an integer to an Item in a combobox as I add the item.
>
>  (I am using a pointer to a record here too, and the only item in
> the record is ID :Integer)
>
>  Combo.Items.Add(rs.rdoColumns[1]);
>
>  New(pNewRec);
>  pNewRec^.ID:=rs.rdoColumns[0];
>  Combo.Items.AddObject('id',TObject(pNewRec));
>
> this seems ok, BUT when I do the following
>
>   ll_Provider:=pRec(cmbReadonly.items.Objects[cmbReadonly.ItemIndex])^.ID;
>
> if I do this, I get an Access violation.....can anyone see what I
> am doing worng....OR suggest a better wat to do it ?
>
> Cheers, Jeremy Coulter
>
>
>
>
> Jeremy Coulter (Manager)
> Visual Software Solutions
> Christchurch, New Zealand
> PH 03-3521595
> FAX 03-3521596
> MOBILE 021-2533214
> www.vss.co.nz
>
> ------------------------------------------------------------------
> ---------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to