Solved

Problem with listboxes

Posted on 1998-09-19
5
166 Views
Last Modified: 2010-04-06
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?
0
Comment
Question by:mathes
  • 3
5 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 10 total points
ID: 1340272
Hi

You need to do it like this:

Edit1.Text := TargetListBox.Items[TargetListBox.ItemIndex];

ListBox.ItemIndex is an Integer, but you need a string of text.  ListBox.Items[???] gives you the string you need.

Regards,
JB
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340273
Here is what you do...

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

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340274
Oh, Jim sorry...you've answered...your answer is even better ;-)

Regards,
Viktor Ivanov
0
 

Author Comment

by:mathes
ID: 1340275
Hi experts,

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

With kind regards

Christian
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340276
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
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now