Today I need a practical idea, how to combine visual and non visual items in the case of a search function.
We start with the visual one:
The user clicks a search button next to a TEdit. He wants to search - let us say - for "animal".
What happens behind the scene: The search goes to a specialize unit, which knows about databases. This unit makes a query, finds the solution and gives it as lines of strings.
E.g. the user searches for animal, then the list would be humming bird, elephant and gorilla.
These "hits" are listed in a TListView (which is nice, but if somebody knows it better, I change it).
Now the user wants to work on with gorilla. He clicks it and the List-View-Click event finds the line.
Now I as programmer - am done:
How on earth was the primary key of gorilla?!!
What does not work is a pointer. Pls do not discuss it, it is not possible.
What I WANT to do is this:
I want the database unit to send something back, which contains the primary keys next to the found strings.
This can be done in several ways:
The ugly one: I use a value of the string list for it and cut it for the view.
This is very ugly, because I have the string values, cuts, conversion to figures again.
A minor ugly way would be to use a HashedStringList. Yes, is a string as well, but not THAT ugly.
So my question to the community (as the topic must be quite common):
Is there a nice solution (remember: pointer will not work) ?
If I do it with HashedStringList: How to combine the type with TListView?
Is there a way just to display ONE values without loosing the hashed value or must I keep my HashedStringList and search on the clickEvent for the second value (which would be my primary key)?