Page 1 of 1

listbox overflow

PostPosted: Wed Jun 07, 2006 9:22 pm
by Modnway
Hi everyone,
I'm new to NeoBook and am working on my first project and would like to thank everyone for all the helpful posts. I have learned an awful lot from all the posts on the many different subjects, without them I would not be this far along.

I am in need of further help and have not found the answer yet in the forums.

Question: I am populating an listbox with a database via Neobook DB,
the database will contain 50 or so items What I want to do is make a book with 2 sides and have one list box on the left and one on the right side each containing 25 items.
I need to know if it is possible to overflow the first listbox into the second because I only want about 25 items per listbox so that you will not have to scroll to see all items within each listbox. I could use 2 different DBs ,one for each side, but want to fill the left side first when a Query is done and then if there are more than 25 results spill over to listbox2.

Maybee I should use another method?
Any help and code examples would be greatly appreciated as I am still pretty new.
Thank you all so much for all the help you've already given me!

Modnway

PostPosted: Thu Jun 08, 2006 4:53 am
by Sam Cox
Following josea.munoz's lead but using ListBox1 and ListBox2, this simpler code might work for you:

Code: Select all
dbfDefineAlias "[pubdir]MyDataBase.dbf" "DB"
dbfOpen "DB" ""
dbfGetRecordCount "DB" "[RecordCount]"

SetVar "[Max]" "25"
SetVar "[Target]" "ListBox1"

ListBoxDeleteItem "ListBox1" "all"
ListBoxDeleteItem "ListBox2" "all"

dbfFirst "DB"
Loop "1" "[RecordCount]" "[N]"
  If "[N]" ">" "[Max]"
    SetVar "[Target]" "ListBox2"
  Endif
  ListBoxAddItem "[Target]" "0" "[DB.TEST]"
  dbfNext "DB"
EndLoop

PostPosted: Sun Jun 11, 2006 8:39 pm
by Modnway
Thanks, Sam and josea for your help.
I came up with a simple solution and am greatful for your help, I will keep your code examples to use on future project as I get better at coding.

My solution:
1) I sent all the data to both listboxes(50 items for left side, same 50 items for right).
2)Deleted items 26-50 in linkbox 1, leaving items 1-25.
3)Deleted items 1-25 in linkbox 2, leaving items 26-50.
This left me with 2 colums, each containing an equal number of items.

Maybe not the best way, but pretty simple and good enough for what I need it for.

By the way I deleted items one at a time, is there a way to delete a bunch of items in a listbox at a time? Again I am still new at this.

Thanks again,
you guys are great!

:D

PostPosted: Mon Jun 12, 2006 12:23 am
by Cipolla
Hello Modnway,

i think Sams code is an elegant way to do the job. I did not thought about changing the target (listbox) inside the loop. This little trick is also usefull for other actions.

As i now it is impossible to delte a bunch of items at one time ( i.e. item 3-15) but you can delete all items by using the parameter "All" for the linenumber.

PostPosted: Sat Sep 02, 2006 12:43 pm
by Jay-Bird
Sam Cox wrote:Following josea.munoz's lead but using ListBox1 and ListBox2, this simpler code might work for you:

Code: Select all
dbfDefineAlias "[pubdir]MyDataBase.dbf" "DB"
dbfOpen "DB" ""
dbfGetRecordCount "DB" "[RecordCount]"

SetVar "[Max]" "25"
SetVar "[Target]" "ListBox1"

ListBoxDeleteItem "ListBox1" "all"
ListBoxDeleteItem "ListBox2" "all"

dbfFirst "DB"
Loop "1" "[RecordCount]" "[N]"
  If "[N]" ">" "[Max]"
    SetVar "[Target]" "ListBox2"
  Endif
  ListBoxAddItem "[Target]" "0" "[DB.TEST]"
  dbfNext "DB"
EndLoop



....Marvelous Sam! Simple and straight.... I know the date of this post is back in June, but I am having to get "Caught up" to the New NB5....this is good stuff, will put this in my Examples Keeper....

Thanks