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

select item in combobox

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


Joined: 14 Jun 2007
Posts: 16

PostPosted: Mon Sep 24, 2007 3:08 pm    Post subject: select item in combobox Reply with quote

Hi,

I`m trying to do this for hours now, and i`m getting frustrated to the point of wanting to jump the roof. Could someone shed some light on why i cant get the selected item in a combobox to change to a certain item or itemindex?

I made a tiny test form for it:

Code:
Break On
$System = CreateObject("KiXforms.System")

$Form1 = $System.Form()
$Form1.Size = $System.Size(164, 140)

$Button1 = $Form1.Controls.Add($System.Button())
$Button1.Size = $System.Size(75, 26)
$Button1.Text = "Button1"
$Button1.Location = $System.Point(36, 53)

$ComboBox1 = $Form1.Controls.Add($System.ComboBox())
$ComboBox1.Location = $System.Point(13, 12)
$ComboBox1.SelectedIndex = -1
$ComboBox1.TabIndex = 0
$ComboBox1.Size = $System.Size(121, 21)
$Form1.Text = "Form1"
$Form1.Click = "test( $$Form1 )"


$ComboBox1.items.add("a")
$ComboBox1.items.add("b")
$ComboBox1.items.add("c")

For Each $item in $ComboBox1.items
      ? $item
Next

$Form1.Show
While $Form1.Visible
   $=Execute($System.Application.DoEvents)
Loop

Function test( $object )

$ComboBox1.selectedindex = 1

EndFunction


As you can see i tried $ComboBox1.selectedindex = 1 and ofcourse the in kixforms classic used $ComboBox1.listindex = 1 and all kinds of combinations.

Thanks in advance for your reply!
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Sep 24, 2007 3:25 pm    Post subject: Reply with quote

You have an extra $ here...

$Form1.Click = "test( $$Form1 )"

Try it as

$Form1.Click = "Test($Form1)"

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
AJ83
KiXforms Follower
KiXforms Follower


Joined: 14 Jun 2007
Posts: 16

PostPosted: Mon Sep 24, 2007 3:40 pm    Post subject: Reply with quote

Thats not the problem. That`s automaticly generated by ScriptForm Designer.

If you use only 1 $, it will even generate an error code:
Code:
ERROR : invalid method/function call: missing required parameter 1!


The issue is, when i click the button, i want the combobox to change the selected item. ( in this test case i want it to show the value @ index 1 )
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Sep 24, 2007 3:56 pm    Post subject: Reply with quote

Actuall looking back at your code there is no reason to pass paramters at all (your snippet does nothing with it).

However I believe (and I could be wrong here), that your index is being selected, but that it does not automatically show on the form.

You can test this by putting into your function

? $combobox1.selectedindex

You may have to redraw the form to make it update, or enter the text entry again .. Here is an example of how I have done it before.

Code:

   $Form1.BackColor = $System.Color.FromName("Control")
   $Textbox1.Text = ""
   $ComboBox1.SelectedIndex = -1
   $ComboBox1.Text = "Month"
   $ComboBox2.SelectedIndex = -1
   $ComboBox2.Text = "Day"
   $ComboBox3.SelectedIndex = -1
   $ComboBox3.Text = "Year"
   
   $ComboBox4.SelectedIndex = -1
   $ComboBox4.Text = "Month"
   $ComboBox5.SelectedIndex = -1
   $ComboBox5.Text = "Day"
   $ComboBox6.SelectedIndex = -1
   $ComboBox6.Text = "Year"


Benny or Shawn will be able to explain it better than I can.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Mon Sep 24, 2007 5:23 pm    Post subject: Reply with quote

Hi AJ83,

If I have this right, you want the pushbutton to change the selected index of the combobox to a specific index (in this case 1).

What you'll need to do is create a Button Click event not a Form Click event.

Code:

Break On
$System = CreateObject("KiXforms.System")

$Form1 = $System.Form()
$Form1.Size = $System.Size(164, 140)
$Form1.Text = "Form1"
$Form1.Click = "test( $$Form1 )"

$Button1 = $Form1.Controls.Add($System.Button())
$Button1.Size = $System.Size(75, 26)
$Button1.Text = "Button1"
$Button1.Location = $System.Point(36, 53)
$Button1.Click = "Button1_Click()"

$ComboBox1 = $Form1.Controls.Add($System.ComboBox())
$ComboBox1.Location = $System.Point(13, 12)
$ComboBox1.SelectedIndex = -1
$ComboBox1.TabIndex = 0
$ComboBox1.Size = $System.Size(121, 21)

$ComboBox1.items.add("a")
$ComboBox1.items.add("b")
$ComboBox1.items.add("c")

For Each $item in $ComboBox1.items
   ? $item
Next

$Form1.Show
While $Form1.Visible
   $=Execute($System.Application.DoEvents)
Loop

Function test( $object )
   $ComboBox1.selectedindex = 1
EndFunction

Function Button1_Click()
   $ComboBox1.selectedindex = 1
EndFunction
Back to top
View user's profile Send private message
AJ83
KiXforms Follower
KiXforms Follower


Joined: 14 Jun 2007
Posts: 16

PostPosted: Tue Sep 25, 2007 6:58 am    Post subject: Reply with quote

Yup, that was the problem, my test form was faulty....i feel quite stupid.
I think i didnt have the button selected in scriptform designer while filling in the event, hence the event on the $form.

Thanks for the help! at least i now know $ComboBox1.selectedindex = 1 works Smile
Back to top
View user's profile Send private message
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