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

Changing Picture via ComboBox

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


Joined: 09 Mar 2006
Posts: 43
Location: Kolding, Denmark

PostPosted: Thu Jun 19, 2008 12:13 pm    Post subject: Changing Picture via ComboBox Reply with quote

Hi there... Very Happy

I have a slight problem and hope that someone in here can help.

I have a form with a picturebox and a combobox.

In the combobox I have some names listet. I want it to work so that if I click a persons name the picture in the picturebox shall change...

I have this code... but It doesn't work...

Code:



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

;KD START

;************* Form **************
$Form = $System.Form()
$Form.BackColor = 240,240,240
$Form.FontSize = 8,25
$Form.Height = 250
$Form.Left = 244
$Form.Text = "KiXforms Designer Template"
$Form.Top = 25
$Form.Width = 250
;**************************************

;************* PictureBox1 **************
$PictureBox1 = $Form.Controls.PictureBox()
$PictureBox1.BackColor = 240,240,240
$PictureBox1.BorderStyle = 1
$PictureBox1.Height = 96
$PictureBox1.Left = 65
$PictureBox1.Picture = "Logo.bmp"
$PictureBox1.Top = 30
$PictureBox1.Width = 96
;**************************************

;************* ComboBox1 **************
$ComboBox1 = $Form.Controls.ComboBox()
$ComboBox1.DropDownWidth = 121
$ComboBox1.FontSize = 8,25
$ComboBox1.Height = 21
$ComboBox1.Left = 15
$ComboBox1.Sorted = "False"
$ComboBox1.Text = ""
$ComboBox1.Top = 150
$ComboBox1.Width = 200
$ComboBox1.Additem ("Logo")
$ComboBox1.Additem ("Person 1")
$ComboBox1.Additem ("Person 2")
$ComboBox1.Additem ("Person 3")
$ComboBox1.OnClick "Picture-change()"
;**************************************


;KD END

$Form.Show
While $Form.Visible
   $=Execute($Form.DoEvents())
Loop
Exit 1

Function Picture-change()
  If $ComboBox1.Text = "Logo"
    $PictureBox1.Picture = "Logo.bmp"
  Endif
 
  If $ComboBox1.Text = "Person 1"
    $PictureBox1.Picture = "ps1.bmp"
  Endif
 
  If $ComboBox1.Text = "Person 2"
    $PictureBox1.Picture = "ps2.bmp"
  Endif
 
  If $ComboBox1.Text = "Person 3"
    $PictureBox1.Picture = "ps3.bmp"
  Endif
Endfunction
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jun 19, 2008 12:37 pm    Post subject: Reply with quote

Try this instead (I may have the exact syntax incorrect, but you should get the idea)

$ComboBox1.SelectedIndexChange = "Picture-Change ()"

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


Joined: 09 Mar 2006
Posts: 43
Location: Kolding, Denmark

PostPosted: Thu Jun 19, 2008 12:52 pm    Post subject: Reply with quote

Hi Gargoyle... !

I searched info on the option and found out that it shall be

$ComboBox1.OnSelectedIndexChanged

... but it didn't change a thing. It still doesn't work.

/Ramalam
Back to top
View user's profile Send private message
Ramalam
KiXforms Regular
KiXforms Regular


Joined: 09 Mar 2006
Posts: 43
Location: Kolding, Denmark

PostPosted: Fri Jun 20, 2008 8:11 am    Post subject: Reply with quote

Hi Gargoyle... Cool Cool Cool

Now I got it working... I added your suggestion and when I changed the 'Picture-Change()' to just 'Picture()' it was working.

Code:



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

;KD START

;************* Form **************
$Form = $System.Form()
$Form.BackColor = 240,240,240
$Form.FontSize = 8,25
$Form.Height = 250
$Form.Left = 244
$Form.Text = "KiXforms Designer Template"
$Form.Top = 25
$Form.Width = 250
;**************************************

;************* PictureBox1 **************
$PictureBox1 = $Form.Controls.PictureBox()
$PictureBox1.BackColor = 240,240,240
$PictureBox1.BorderStyle = 1
$PictureBox1.Height = 96
$PictureBox1.Left = 65
$PictureBox1.Picture = "Logo.bmp"
$PictureBox1.Top = 30
$PictureBox1.Width = 96
;**************************************

;************* ComboBox1 **************
$ComboBox1 = $Form.Controls.ComboBox()
$ComboBox1.DropDownWidth = 121
$ComboBox1.FontSize = 8,25
$ComboBox1.Height = 21
$ComboBox1.Left = 15
$ComboBox1.Sorted = "False"
$ComboBox1.Text = ""
$ComboBox1.Top = 150
$ComboBox1.Width = 200
$ComboBox1.Additem ("Logo")
$ComboBox1.Additem ("Person 1")
$ComboBox1.Additem ("Person 2")
$ComboBox1.Additem ("Person 3")
$ComboBox1.OnSelectedIndexChanged = "Picture()"
$ComboBox1.OnTextChanged = "Picture()"
$ComboBox1.OnClick = "Picture()"
;**************************************


;KD END

$Form.Show
While $Form.Visible
   $=Execute($Form.DoEvents())
Loop
Exit 1

Function Picture()
  If $ComboBox1.Text = "Logo"
    $PictureBox1.Picture = "Logo.bmp"
  Endif
 
  If $ComboBox1.Text = "Person 1"
    $PictureBox1.Picture = "ps1.bmp"
  Endif
 
  If $ComboBox1.Text = "Person 2"
    $PictureBox1.Picture = "ps2.bmp"
  Endif
 
  If $ComboBox1.Text = "Person 3"
    $PictureBox1.Picture = "ps3.bmp"
  Endif
Endfunction


/Ramalam
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Jun 20, 2008 12:27 pm    Post subject: Reply with quote

You have to be carefull when using a - in scripting. Many times it is seen as an operator. So KiX was seeing it as "picture" minus "change".

Glad you got it working.

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


Joined: 09 Mar 2006
Posts: 43
Location: Kolding, Denmark

PostPosted: Fri Jun 20, 2008 12:53 pm    Post subject: Reply with quote

Hi Gargoyle... Very Happy

Ahhhh... OK, thanks for the advice.

/Tonny
Back to top
View user's profile Send private message
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