Solved

TEdit Text Replacement function

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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