Link to home
Start Free TrialLog in
Avatar of mathes
mathes

asked on

Problem with listboxes

Hi experts,

I have a problem with Listboxes.

How can I assign the content of the currently selected item of a listbox to
a TEdit control?

I tried it like this

procedure TargetListBoxClick(Sender: TObject);
begin
Ā Edit1.Text:=TargetListbox.itemindex;
end;

but here Delphi complains about incompatible data types
(string and integer)

Any suggestions for a correct solution?
ASKER CERTIFIED SOLUTION
Avatar of JimBob091197
JimBob091197

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is what you do...

DaEdit.Text := DaListBox.Items.Strings[DaListBox.ItemIndex];

Regards,
Viktor Ivanov
Oh, Jim sorry...you've answered...your answer is even better ;-)

Regards,
Viktor Ivanov
Avatar of mathes
mathes

ASKER

Hi experts,

thank you all for your comments. This is exactly what I was looking for.

With kind regards

Christian
I just added Listbox.Items.Strings[Listbox.ItemIndex];
because in Builder C++ you can not use only Items[] and need to use Item.Strings[]

Otherwise the idea is the same ;-)

Regards,
Viktor Ivanov