Solved

Problem with listboxes

Posted on 1998-09-19
5
175 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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