KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

How to enum ListBox contents

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
pgilardi
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Oct 2003
Posts: 11
Location: Milano - Italy

PostPosted: Tue Oct 28, 2003 10:49 am    Post subject: How to enum ListBox contents Reply with quote

I need to construct an array with the content of a listbox.
The only way i've found is to loop on ListIndex and load the array elements with $ListBox.Text. All it's ok but of course
the listbox selection is shown scrolling down in the form as ListIndex is incremented 1 by 1 on each loop cycle.
Before thinking to convert the listbox to a ListView object and then using .Items, i wonder if there is another way to get the same result while maintaining the listbox.
Thanks in advance for any suggestion.
paolo
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Tue Oct 28, 2003 12:20 pm    Post subject: Reply with quote

Yeah,

still the .List Property is write-only Sad
If you try it with a ListView this thread on korg might be of interest for you :
ListView into an Array

Here is another one handling the ComboBox :
Need a workaround for the WRITE-ONLY List Property

hth

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
pgilardi
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Oct 2003
Posts: 11
Location: Milano - Italy

PostPosted: Tue Oct 28, 2003 6:24 pm    Post subject: re: enum listbox Reply with quote

thanks jochen, i'll give a try.
for the moment i'm go on using the following code: as said it works pretty good even if you get the autoscroll of index inside the listbox. after all,
not so big issue (anycase i restore initial index when finished).
in the example i abstracted from a longest code, i get all listbox content and write it onto a .ini file.
$CurrentIndex = $ListBox1.ListIndex
For $i = 0 to $ListBox1.ListCount-1
$ListBox1.ListIndex = $i
$=WriteProfileString($INIFile, $RegSection, $RegKey, $ListBox1.Text)
Next
$ListBox1.ListIndex = $CurrentIndex

thanks,
paolo
Back to top
View user's profile Send private message
pgilardi
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Oct 2003
Posts: 11
Location: Milano - Italy

PostPosted: Tue Oct 28, 2003 11:45 pm    Post subject: solved Reply with quote

i got what i needed with this script:
$CurrentIndex = $ListBox1.ListIndex
$ListBox1.BeginUpdate
For $i = 0 to $ListBox1.ListCount-1
$ListBox1.ListIndex = $i
$=WriteProfileString($INIFile, $RegSection, $RegKey, $ListBox1.Text)
Next
$ListBox1.ListIndex = $CurrentIndex
$ListBox1.EndUpdate

(with begin/end update no scroll shown inside the control).
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Oct 29, 2003 7:13 am    Post subject: Reply with quote

Yeah,

allthough I had my troubles with begin/endupdate in the last view releases (regarding graphical things) it is a possibility in your case...

Still I'd vote for making the list property read-write Nod

Think I'll make an entry in the feature list

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Thu Oct 30, 2003 5:18 am    Post subject: List Box Reply with quote

here is code i use for moving lists from one list box to another, maybe it will help.

These Functions are based on the thought that you are useing buttons
created as follows:

Add All
Add
Remove
Remove All

with the Button1.OnClick =
ex. Button1.OnClick = "AddAllToGroup()"


Function AddAllToGroup()
For $x = 0 to $ListBox1.ListCount
$ListBox2.AddItem($ListBox1.List($x))
Next
EndFunction

;This Function will add a single choice in alphabetic order
;if it does not already exist.
Function AddToGroup()
$ListItem = "No"
For $x = 0 to $ListBox2.ListCount
If $ListBox2.List($x) = $ListBox1.Text
$ListItem = "Yes"
EndIf
Next
If $ListItem = "No"
$ListBox2.AddItem($ListBox1.Text)
EndIf
EndFunction

Function RemoveFromGroup()
$ListBox2.RemoveItem($ListBox2.ListIndex)
EndFunction

Function RemoveAllFromGroup()
$ListBox2.Clear
EndFunction
Code:

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
pgilardi
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Oct 2003
Posts: 11
Location: Milano - Italy

PostPosted: Fri Oct 31, 2003 5:38 pm    Post subject: list property ? Reply with quote

uhm: is really .List property working well with listboxes ?
i got issues on this in the past; anyway i'll give a try: thanks for post 'benny69'.
paolo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group