Source language: Translate to:

listbox overflow

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

listbox overflow

Postby Modnway » Wed Jun 07, 2006 9:22 pm

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
Modnway
 
Posts: 7
Joined: Wed Jun 07, 2006 10:21 am

Postby Sam Cox » Thu Jun 08, 2006 4:53 am

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
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Modnway » Sun Jun 11, 2006 8:39 pm

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
Modnway
 
Posts: 7
Joined: Wed Jun 07, 2006 10:21 am

Postby Cipolla » Mon Jun 12, 2006 12:23 am

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.
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Postby Jay-Bird » Sat Sep 02, 2006 12:43 pm

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
User avatar
Jay-Bird
 
Posts: 164
Joined: Fri Apr 01, 2005 7:01 am
Location: Louisiana , USA


Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 2 guests

cron