Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I would like to click on a item in a listbox and then have the item displayed in a richedit.
Thank You

What I have tried:

procedure TForm1.Button1Click(Sender: TObject);
var
sItem:string;
begin
sItem:=ListBox1.Items[0];
RichEdit1.Lines.Add(sItem);

end;
Posted
Updated 20-Oct-21 8:16am

1 solution

Assuming you have ListBox1.MultiSelect equals false and are interested only in the currently clicked item, then...

Sorry I only know the c++ syntax, but I think should be easy for you to abstract my mixed 'if' example below ;)

Pascal
if (ListBox1.ItemIndex >= 0)
   RichEdit1.Lines.Add(ListBox1.Items[ListBox1.ItemIndex]);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900