Solved

Problem with listboxes

Posted on 1998-09-19
5
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month6 days, 14 hours left to enroll

623 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