Solved

TEdit Text Replacement function

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now