Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge two list boxes

Status
Not open for further replies.

tarja311

Programmer
Jan 23, 2007
7
US
Hello,

I have two list boxes (TListBox). Both containing user-specific directory locations.

My program reads in the directory location(s) of one of the list boxes and displays the files onto a list view (TListView). This works great.

The problem i have is merging the second list box in with the first list box so the results have items from both list boxes.

The results are going into a single string variable. Somehow, I should be able to put both list boxes into that one variable just like how it works right now, with just the one list box.
------------------------------------------
Code:
var results : string;
RN : integer;
// ROOTS is a TStringList

RN := 0;

results := ROOTS[RN - 1];
------------------------------------------

Any ideas?

Thanks
 
to add an item to a stringlist its
Roots.Add('string');

so to add the selected item of a listbox its
Roots.Add(listbox1.Items[listbox.ItemIndex]);

to add all items of a listbox its
var a: integer;
for a = 0 to listbox.Count -1 do
Roots.Add(listbox1.Items[a]);


Aaron
 
if you want to add a string to an existing string in a stringlist its
roots.Strings[0] := roots.Strings[0] + 'new string';

or in your example to add a stringlist item and a new string its

results := roots.Strings[0] + 'new string';


Aaron
 
Thanks for replying.

If I use the Roots.Add(listbox1.Items[a]); code, that simply adds the items of the second list box to the first one. I am trying to keep both list boxes separate from each other. I just want the items of both list boxes displayed together without actually appending to one or the other.

The reason :

I am building a client to client program with two features. Public folders and Private folders. If one client has access to both public and private, then they receive the results from both list boxes.

Any ideas? and thanks again.
 
Much of this question is determined what you mean by the word "merge".

You've made it clear that simply adding the contents of one listbox to the other is not what you're wanting, despite that it would have fulfilled the requirements as you stated them in the first post. I suppose you are wanting the contents of both list boxes to a third one? Or is there something else that you want that makes it harder than that.

A tip for you: One thing to learn about programming is that you need to be able to explicitly define the requirements of the program you are working on. Your success in doing that is shown by your ability to communicate those requirements to another person in a way that is understandable and clear to them.

I offer this because you indicated that the other posters of the thread did not understand the requirements in your question. And I will admit that I do not understand them either. Now I, or anyone else, don't mind helping you here, but it would benefit you if we could understand what you are needing help with.

----------
Measurement is not management.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top