Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem with listboxes

Posted on 1998-09-19
5
Medium Priority
?
181 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 30 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Integration Management Part 2

886 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