BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to save a value from a list box into a record

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Jan 26, 2007 9:11 am    Post subject: How to save a value from a list box into a record Reply with quote



I'm new to Delphi and am having a few problems with saving an item from
a list box on my form into a record.

What data type do I need to set up my record as and how do I implement
assigning the value selected by the user from my list box into my
record?

Here is the declaration of my record (CustomerCar is the field I want
to save the list box data to):

Booking=Record
CustomerCar:String[100];
Date:String[8];
Time:String[5];
MOT:Boolean;
Service:Boolean;
Comments:String[255];
end;

....

procedure TFormAddBooking.btnOkClick(Sender: TObject);
begin
with BookingRecord do
begin
CustomerCar:=LstCustCar //What goes here?//
...

Date:=TxtDate.Text;
end;
end;
Back to top
leehanken
Guest





PostPosted: Sat Jan 27, 2007 4:40 am    Post subject: Re: How to save a value from a list box into a record Reply with quote



hope this helps:

procedure TFormAddBooking.btnOkClick(Sender: TObject);
var
index : Integer;
begin
index := LstCustCar.ItemIndex;
with BookingRecord do
begin
CustomerCar:=LstCustCar.Items[index];
....

On 26 Jan, 09:07, timn...@gmail.com wrote:
Quote:
I'm new to Delphi and am having a few problems with saving an item from
a list box on my form into a record.

What data type do I need to set up my record as and how do I implement
assigning the value selected by the user from my list box into my
record?

Here is the declaration of my record (CustomerCar is the field I want
to save the list box data to):

Booking=Record
CustomerCar:String[100];
Date:String[8];
Time:String[5];
MOT:Boolean;
Service:Boolean;
Comments:String[255];
end;

...

procedure TFormAddBooking.btnOkClick(Sender: TObject);
begin
with BookingRecord do
begin
CustomerCar:=LstCustCar //What goes here?//
...

Date:=TxtDate.Text;
end;
end;
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.