View Full Version : Prob with listboxes
TheProg
10-21-2007, 03:24 PM
Hi!
So I have about 4 or 5 list boxes in my app, 1-2 per page, which when shown populate from files just fine, but the prob I have is that whenever I navigate to different pages and then come back to them, they keep populating and I get a duplicate of what Ive already got.
So to summarise: whenever I goto a different page and then back again, I have double the entries, 2 for each instead of 1.
What do I need to do to make this not happen?
mindstitchdr
10-21-2007, 03:50 PM
Try this:
nItemCount = ListBox.GetCount("ListBox1");
if nItemCount ~= -1 and nItemCount ~= 0 then
--insert action here
else
--insert action here
end
longedge
10-21-2007, 03:52 PM
Not specific to your problem, it's what I do if I only want to see or hear things once. Set a variable when leaving a page and when going to the page, in the pre-load or on show check for it. If it's not there then you haven't been to the page before and need to run code else you have and don't run it.
TheProg
10-21-2007, 04:52 PM
right, I officially have no idea on what you mean!
Here is the current code: tblExtraApps = File.Find("AutoPlay\\Extra Apps", "*.exe", true, false)
if tblExtraApps ~= nil then
for i,v in tblExtraApps do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplitPath.Filename, v)
end
end
which has worked for me before in the past.
Also, here is a screenshot of my program so you can get a better idea of what it is.
azmanar
10-21-2007, 04:58 PM
Hi,
If your Page OnShow autopopulates the ListBox from a source, during application runtime your ListBox will be populated again everytime you enter it.
What you need to do is to AUTODELETE whats listed in the ListBox everytime you enter using ListBox.DeleteItem("ListBox1", -1); and REPOPULATE it immediately from the same source you used earlier. Place both actions on the same Page OnShow.
mindstitchdr
10-21-2007, 04:58 PM
nItemCount = ListBox.GetCount("ListBox1");
if nItemCount ~= -1 and nItemCount ~= 0 then
--insert action here
else
tblExtraApps = File.Find("AutoPlay\\Extra Apps", "*.exe", true, false)
if tblExtraApps ~= nil then
for i,v in tblExtraApps do
tblSplitPath = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplitPath.Filename, v)
end
end
end
TheProg
10-21-2007, 05:09 PM
Thanks, this works perfectly! :)
I have this sidebar at the end of the right hand side, how would I go about auto-hiding it and when I move the mouse to the right hand side, it would auto-show?
this would be awesome!
azmanar
10-22-2007, 03:44 AM
Hi,
You should test Worm's Pop-up plugin. If u like it, buy it.
And use HOTSPOT object to call the plugin once the mouse passes thru an area you specified.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.