I have a Record that I would like to store for each Item that add to a Listbox. Would I need to make the record a class instead to accomplish this?
TServerRec = record
ID: integer;
DisplayName: string;
Address: string;
Port: integer;
end;
procedure TMainForm.PopuplateServers;
var
server: TServerRec;
begin
for server in FServerList do
begin
lbServers.AddObject(server.DisplayName, server);
end;
end;
No, but you could store a pointer to this record with a bit of typecasting. But then you’re getting into dynamic record pointer allocation, which can be a bit of a headache. Why not make TServerRec into an object?