Solved

TEdit Text Replacement function

Posted on 2009-03-29
2
360 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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