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

please help with "ListBox.SelectedIndices"

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


Joined: 25 Oct 2007
Posts: 7
Location: Kassel, Germany

PostPosted: Thu Oct 25, 2007 1:55 pm    Post subject: please help with "ListBox.SelectedIndices" Reply with quote

Hi, I am using KiXforms.NET Version 3.2.14 (under development).
I try to create two ListBoxes. On the left hand the $ListBox1 contains a lot of entries and the second one on the right is empty. Between these two ListBoxes there are Buttons. If in the left ListBox1 (SelectionMode=MultiExtend) some entries are selected and a button is pressed these entries should move to the ListBox2. The second Button offers the command in opposite direction.
I do not need the selected Indices within the box, I need the text the ListBox shows the user.



Test_Panel3.kix
 Description:

Download
 Filename:  Test_Panel3.kix
 Filesize:  4.43 KB
 Downloaded:  1064 Time(s)

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: Thu Oct 25, 2007 6:16 pm    Post subject: Reply with quote

Howdy Joe66, and welcome to the board.

here is a quick example of how to use ListBox's:

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

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(338,224) ;(Width,Height)
$Form1.Text = "ListBox Example"
$Form1.Top = 0

$ListBox1 = $System.ListBox()
$ListBox1.DoubleClick = "AddToListBox2()"
$ListBox1.Height = 173
$ListBox1.Left = 10
$ListBox1.Top = 10
$nul = $Form1.Controls.Add($ListBox1)

For $Index = 1 to 6
  $Item = $ListBox1.Items.Add("Line"+$Index)
Next

$Button1 = $System.Button()
$Button1.Click = "AddAllToListBox2()"
$Button1.Height = 30
$Button1.Left = 150
$Button1.Text = ">>"
$Button1.Top = 30
$Button1.Width = 30
$nul = $Form1.Controls.Add($Button1)

$Button2 = $System.Button()
$Button2.Click = "AddToListBox2()"
$Button2.Height = 30
$Button2.Left = 150
$Button2.Text = ">"
$Button2.Top = 70
$Button2.Width = 30
$nul = $Form1.Controls.Add($Button2)

$Button3 = $System.Button()
$Button3.Click = "RemoveFromListBox2()"
$Button3.Height = 30
$Button3.Left = 150
$Button3.Text = "<"
$Button3.Top = 110
$Button3.Width = 30
$nul = $Form1.Controls.Add($Button3)

$Button4 = $System.Button()
$Button4.Click = "RemoveAllFromListBox2()"
$Button4.Height = 30
$Button4.Left = 150
$Button4.Text = "<<"
$Button4.Top = 150
$Button4.Width = 30
$nul = $Form1.Controls.Add($Button4)

$ListBox2 = $System.ListBox()
$ListBox2.DoubleClick = "RemoveFromListBox2()"
$ListBox2.Height = 173
$ListBox2.Left = 200
$ListBox2.Top = 10
$nul = $Form1.Controls.Add($ListBox2)

$Form1.Show  ;Displays the Form

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

Function AddAllToListBox2()

   $ListBox2.Items.Clear
   For $x = 0 to $ListBox1.Items.Count
      If $ListBox1.Items.Item($x) <> ""
         $Item = $ListBox2.Items.Add($ListBox1.Items.Item($x))
      EndIf
   Next
   
EndFunction

Function AddToListBox2()
   
   $ListItem = "No"
   For $x = 0 to $ListBox2.Items.Count
    If $ListBox2.Items.Item($x) = $ListBox1.SelectedItem
         $ListItem = "Yes"
      EndIf
   Next
   If $ListItem = "No"
      $Item = $ListBox2.Items.Add($ListBox1.SelectedItem)
   EndIf
   
EndFunction

Function RemoveFromListBox2()
   
   $ListBox2.Items.Remove($ListBox2.SelectedItem)

EndFunction

Function RemoveAllFromListBox2()

   $ListBox2.Items.Clear

EndFunction

_________________
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
Joe66
KiXforms Dabbler
KiXforms Dabbler


Joined: 25 Oct 2007
Posts: 7
Location: Kassel, Germany

PostPosted: Thu Oct 25, 2007 7:42 pm    Post subject: Reply with quote

Hi benny69 and thank you for the fast reply.
It was not exactly what I was searching for but it gave me the deciding hint:
I tried "$ListBox1.Item($x)" or "$ListBox1.Items" but never together like your example "$ListBox1.Items.Item($x)".
Thanks!
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: Fri Oct 26, 2007 2:50 am    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 -> KiXforms.NET 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