Hello all
I am working on VCL development for a change at the moment. I am trying to use TListBox and getting a little lost.
I fill the listbox with items like so:
My problem is, when I want to save back to the database from the “selected items” listbox, how do I cast the item’s “object” value to integer?
I must say I must be getting too used to Visual Studio, I found myself quite disappointed that I couldn’t just bind workzonename to listbox.displayfield and workzoneid to listbox.valuefield
Perhaps I am going totally the wrong way? Any advice before I waste too much time on this?
Cheers
Tracey
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!
I am working on VCL development for a change at the moment. I am trying to use TListBox and getting a little lost.
I fill the listbox with items like so:
Code:
//Run a Query, return some records
First;
while not eof do
begin
lbMapTo.Items.AddObject(FieldByName('workzonename').AsString,
TObject(FieldByName('workzoneid').AsInteger));
Next;
end;
procedure TfrmWorkZones.btnSelectOSMOSClick(Sender: TObject);
var
i: integer;
begin
//loop through lbOSMOS items to find the selected item.
for i := 0 to lbOSMOS.Items.Count - 1 do
begin
if lbOSMOS.Selected[i] then
lbSelectedOsmos.Items.AddObject(lbOSMOS.Items.Strings[i], lbOSMOS.Items.Objects[i])
end;
lbOSMOS.DeleteSelected;
end;
My problem is, when I want to save back to the database from the “selected items” listbox, how do I cast the item’s “object” value to integer?
I must say I must be getting too used to Visual Studio, I found myself quite disappointed that I couldn’t just bind workzonename to listbox.displayfield and workzoneid to listbox.valuefield
Perhaps I am going totally the wrong way? Any advice before I waste too much time on this?
Cheers
Tracey
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!