Solved

TEdit Text Replacement function

Posted on 2009-03-29
2
358 Views
Last Modified: 2012-05-06
Hey all,

Hope I can explain this somewhat good.

I have 12 TEdit placed on my form, all filled with different names in the text field. Also, I have a Listbox1 filled with all the names + 10 to 15 other names.

When the user clicks on one of the names in the Listbox1, the name gets chosen and the user gets to choose on which TEdit (out of the 12) to place the name.

No problem so far; however, if the name chosen already exists on another TEdit then those two TEdit should be swapped with eachother.

Example:

Edit1.Text := 'Johnson';
Edit2.Text := 'Anderson';
Edit3.Text := 'Swanson';

Listbox1 contains the names Peterson, Swanson, Anderson, Johnson, Perry.

Let's say the user picks 'Swanson' from the Listbox1 and then clicks on Edit1 (Edit1.Text := Listbox1.Items[Listbox1.ItemIndex]) - then, as Swanson already exists on Edit3, Johnson and Swanson should just switch place from Edit3<->Edit1.

And the new result would be:

Edit1.Text := 'Swanson';
Edit2.Text := 'Anderson';
Edit3.Text := 'Johnson';

What would be the most efficient way to achieve this, with as little code as possible? Seeing as this code would have to be on every Edit*.click; ?

Hope you understood me somewhat, otherwise I'll be happy to give it another try :)
0
Comment
Question by:MerlaP83
2 Comments
 
LVL 13

Accepted Solution

by:
ThievingSix earned 250 total points
ID: 24015311
https://filedb.experts-exchange.com/incoming/ee-stuff/7588-Q_24275851.zip

This should work for you. Kind of a basic example but it works.
0
 

Author Closing Comment

by:MerlaP83
ID: 31564118
Basic, but worked like I expected and wanted to.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 166
Delphi component that can load a DLL in design time? 8 74
Delphi selector screen 2 84
Show Listview image from database (String field) 5 137
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 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