PDA

View Full Version : Listbox from listbox


idiogene
04-30-2008, 12:53 PM
Hi, I know it should be simple, but I can't figure it out.

I would like to add a selection of items from listbox1 to listbox2.

Listbox1 has 90 items listed in and I need to index the 20 items located between lines 20 to 40 in a second listbox (listbox2).

Could anyone help me with this?

Idiogene

idiogene
04-30-2008, 05:39 PM
Ok, after many try I found a way.
-----
function list1tolist2()
count = 19;
repeat
count = count + 1;
resultD = ListBox.GetItemData("listbox1", count);
resultT = ListBox.GetItemText("listbox1", count);
ListBox.AddItem("listbox2", resultT, resultD);
until count 40
end
----
It might not be the best way but at least it works

Thank's

Idiogene

RizlaUK
04-30-2008, 06:11 PM
yes, it works and theres nothing wrong with it

this just makes it a little more *dynamic*

function list1tolist2(strOBJ1,strOBJ2)
local nCount = ListBox.GetCount(strOBJ1);
for index = 1, nCount do
local resultD = ListBox.GetItemData(strOBJ1, index);
local resultT = ListBox.GetItemText(strOBJ1, index);
ListBox.AddItem(strOBJ2, resultT, resultD);
end
end

-- Test
list1tolist2("listbox1","listbox2")

idiogene
04-30-2008, 07:02 PM
I see said the blind man.
That's what I was looking for and didn't know how to ask for.
.. it's much more *dynamic*.:D
Thank you,

Idiogene

RizlaUK
04-30-2008, 08:03 PM
lol, no problem :yes

i just read you 1st post properly, i dident see the > 20 and < 40 thing i just looked at your function

add the bits in red to only add items 20 to 40
function list1tolist2(strOBJ1,strOBJ2)
local nCount = ListBox.GetCount(strOBJ1);
for index = 1, nCount do
if index > 20 and index < 40 then
local resultD = ListBox.GetItemData(strOBJ1, index);
local resultT = ListBox.GetItemText(strOBJ1, index);
ListBox.AddItem(strOBJ2, resultT, resultD);
end
end
end

list1tolist2("ListBox1","ListBox2")

idiogene
05-01-2008, 12:52 PM
Tested... Yes! It works wonderfully.
Again, thank you very much RizlaUK for this lesson of syntax.

Idi:)gene