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

Problem to read value with listbox.net

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
ragus
KiXforms Follower
KiXforms Follower


Joined: 10 Apr 2005
Posts: 27
Location: Europe - France

PostPosted: Tue Oct 24, 2006 11:33 am    Post subject: Problem to read value with listbox.net Reply with quote

Hi!

how to recover the data of the listbox?

Ragus

Code:
Break On
$System = CreateObject("Kixforms.System")
If NOT $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(372,273) ;(Width,Height)
$Form1.Text = "Form1"
$Form1.Top = 0

$ListBox1 = $System.ListBox()
$ListBox1.Height = 199
$ListBox1.IntegralHeight = 0
$ListBox1.Left = 10
$ListBox1.Top = 15
$ListBox1.Width = 160
$nul = $Form1.Controls.Add($ListBox1)


$TextBox1 = $System.TextBox()
$TextBox1.Height = 190
$TextBox1.Left = 195
$TextBox1.MultiLine = -1  ;True
$TextBox1.Text = ""
$TextBox1.Top = 20
$TextBox1.Width = 135
$nul = $Form1.Controls.Add($TextBox1)

$Form1.Show  ;Displays the Form

$ListBox1.Items.Add("alpha" + @CRLF)
$ListBox1.Items.Add("beta" + @CRLF)
$ListBox1.Items.Add("alpha 2" + @CRLF)
$ListBox1.Items.Add("beta 2" + @CRLF)
$ListBox1.Items.Add("alpha 3"+ @CRLF)
$ListBox1.Items.Add("beta 3"+ @CRLF)
$ListBox1.Items.Add("alpha 4"+ @CRLF)
$ListBox1.Items.Add("beta 4"+ @CRLF)

?
? "result " + $ListBox1.Items.Count
?
   
For $Index = 2 to 6
   
     ? $ListBox1.Items($Index).Text
   
Next $Index

While $Form1.Visible
   $Nul = Execute($Form1.DoEvents())
Loop
Exit 0
Back to top
View user's profile Send private message Send e-mail
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Tue Oct 24, 2006 12:30 pm    Post subject: Reply with quote

Hi Ragus,
When you add a Item to a ListBox you want to Silence it by assigning it to a varible.

Code:

$nul = $ListBox1.Items.Add("alpha 1" + @CRLF)


Items that are a part of a listbox collection do not have a '.Text' property
and are accessed in this format:

Code:

$ListBox1.Items.Item($Index)


You would want to do something like this:

Code:

For $Index = 0 to $ListBox1.Items.Count -1
   ? $ListBox1.Items.Item($Index)
Next


Here is your modified code:

Code:

Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(372,273) ;(Width,Height)
$Form1.Text = "Form1"
$Form1.Top = 0

$ListBox1 = $System.ListBox()
$ListBox1.Height = 199
$ListBox1.IntegralHeight = 0
$ListBox1.Left = 10
$ListBox1.Top = 15
$ListBox1.Width = 160
$nul = $Form1.Controls.Add($ListBox1)

$TextBox1 = $System.TextBox()
$TextBox1.Height = 190
$TextBox1.Left = 195
$TextBox1.MultiLine = -1  ;True
$TextBox1.Text = ""
$TextBox1.Top = 20
$TextBox1.Width = 135
$nul = $Form1.Controls.Add($TextBox1)

$Form1.Show  ;Displays the Form

$nul = $ListBox1.Items.Add("alpha 1" + @CRLF)
$nul = $ListBox1.Items.Add("beta 1" + @CRLF)
$nul = $ListBox1.Items.Add("alpha 2" + @CRLF)
$nul = $ListBox1.Items.Add("beta 2" + @CRLF)
$nul = $ListBox1.Items.Add("alpha 3"+ @CRLF)
$nul = $ListBox1.Items.Add("beta 3"+ @CRLF)
$nul = $ListBox1.Items.Add("alpha 4"+ @CRLF)
$nul = $ListBox1.Items.Add("beta 4"+ @CRLF)

?
? "result " + $ListBox1.Items.Count
?

For $Index = 0 to $ListBox1.Items.Count -1
   ? $ListBox1.Items.Item($Index)
Next

While $Form1.Visible
   $Nul = Execute($Form1.DoEvents())
Loop
Exit 0

_________________
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
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Oct 24, 2006 12:36 pm    Post subject: Reply with quote

Benny I was just about to respond as with the exact same solution.... You type to fast Smile
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Tue Oct 24, 2006 12:37 pm    Post subject: Reply with quote

Laughing
_________________
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
ragus
KiXforms Follower
KiXforms Follower


Joined: 10 Apr 2005
Posts: 27
Location: Europe - France

PostPosted: Tue Oct 24, 2006 12:50 pm    Post subject: Reply with quote

It is perfect thank you very much and also for the explanations

Ragus
Back to top
View user's profile Send private message Send e-mail
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Tue Oct 24, 2006 12:51 pm    Post subject: Reply with quote

Glad i could help
_________________
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
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic 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