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 ComboBox SelectedIndex programmatically triggers...

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


Joined: 27 Jan 2004
Posts: 332

PostPosted: Wed Oct 17, 2007 11:57 pm    Post subject: Changing ComboBox SelectedIndex programmatically triggers... Reply with quote

I've noticed in KF.NET, changing the ComboBox SelectedIndex programmatically triggers the ComboBox's SelectedIndexChanged event.

This is different behavior than KF.Classic.

Here are two code samples. First one is KF.Classic where SelectedIndexChanged event is NOT triggered. Last one is KF.NET where SelectedIndexChanged event IS triggered.

If this is expected behavior from .NET, how is it possible to set the ComboBox value w/o triggering the SelectedIndexChanged event?

EDIT: Also is it possible to implement FindString method as shown here: http://msdn2.microsoft.com/en-us/library/system.windows.forms.combobox(vs.80).aspx

Copy and paste link.

KF.Classic
Code:

;region ScriptForm Designer

Global $i
$i = 1

;region Constructor

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

;endregion

;region Post-Constructor Custom Code

;endregion

;region Form Creation
;Warning: It is recommended that changes inside this region be handled using the ScriptForm Designer.
;When working with the ScriptForm designer this region and any changes within may be overwritten.

;~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Form1 = $System.Form()
$Form1.Size = 300, 198
$Form1.Text = "Form1"
;~~< ComboBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ComboBox1 = $Form1.Controls.ComboBox()
$ComboBox1.Location = 89, 86
$ComboBox1.List = "1", "2", "3", "4", "5", "6", "7"
$ComboBox1.Size = 121, 21
$ComboBox1.OnSelectedIndexChanged = "ComboBox1OnSelectedIndexChanged( $$ComboBox1 )"
;~~< Button1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button1 = $Form1.Controls.Button()
$Button1.Size = 67, 34
$Button1.Text = "Button1"
$Button1.Location = 112, 118
$Button1.OnClick = "Button1Click( $$Button1 )"

;endregion

;region Custom Code

;endregion

;region Event Loop

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

;endregion

;region Event Handlers

Function ComboBox1OnSelectedIndexChanged( $object )
   ? "ComboBox1OnSelectedIndexChanged()"
EndFunction

Function Button1Click( $object )
   ? "Button1Click()"   
   $ComboBox1.SelectedIndex = $i
   $i = $i + 1
EndFunction

;endregion

;endregion


KF.NET
Code:

;region ScriptForm Designer

Global $i
$i = 1

;region Constructor

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

;endregion

;region Post-Constructor Custom Code

;endregion

;region Form Creation
;Warning: It is recommended that changes inside this region be handled using the ScriptForm Designer.
;When working with the ScriptForm designer this region and any changes within may be overwritten.

;~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Form1 = $System.Form()
$Form1.Size = $System.Size(300, 178)
$Form1.Text = "Form1"
;~~< Button1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button1 = $Form1.Controls.Add($System.Button())
$Button1.TabIndex = 1
$Button1.Size = $System.Size(75, 23)
$Button1.Text = "Button1"
$Button1.Location = $System.Point(107, 97)
$Button1.Click = "Button1_Click( $$Button1 )"
;~~< ComboBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ComboBox1 = $Form1.Controls.Add($System.ComboBox())
$ComboBox1.Location = $System.Point(86, 61)
;~~< ComboBox1.Items >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ComboBox1Items1 = $ComboBox1.Items.Add("1")
$ComboBox1Items2 = $ComboBox1.Items.Add("2")
$ComboBox1Items3 = $ComboBox1.Items.Add("3")
$ComboBox1Items4 = $ComboBox1.Items.Add("4")
$ComboBox1Items5 = $ComboBox1.Items.Add("5")
$ComboBox1Items6 = $ComboBox1.Items.Add("6")
$ComboBox1Items7 = $ComboBox1.Items.Add("7")
$ComboBox1.TabIndex = 0
$ComboBox1.Size = $System.Size(121, 21)
$ComboBox1.SelectedIndexChanged = "ComboBox1_SelectedIndexChanged( $$ComboBox1 )"

;endregion

;region Custom Code

;endregion

;region Event Loop

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

;endregion

;region Event Handlers

Function Button1_Click( $object )
   ? "Button1_Click()"
   $ComboBox1.SelectedIndex = $i
   $i = $i + 1   
EndFunction

Function ComboBox1_SelectedIndexChanged( $object )
   ? "ComboBox1_SelectedIndexChanged()"
EndFunction

;endregion

;endregion
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