Can MULTIPLE CONTROLS trigger the same CODE?
2020-11-02-180830
All --
I have a APP with a large number of CHECKBOXES.
I would like the same routine to be triggered when the
checkBox1.CheckedChanged
is triggered.
The INTERNET says that I should be able to chain these .CheckChanged together and connect multiple events to a single event handler in Visual Basic as shown below with a BUTTON EXAMPLE.
<span>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click ' Add event-handler code here. End Sub </span>
I attempted this in CODE within the PROJECT WORKBENCH. The WORKBENCH does not like the list when it is connected by commas
Private Sub checkBox1_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) _ Handles checkBox1.CheckedChanged, checkBox2.CheckedChanged 'Debug.print "--- checkBox1_CheckedChanged CheckChangedWorker() End Sub
or when it is just separated by spaces
Private Sub checkBox1_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) _ Handles checkBox1.CheckedChanged checkBox2.CheckedChanged 'Debug.print "--- checkBox1_CheckedChanged CheckChangedWorker() End Sub
Is there a way to make the WORKBENCH HAPPY and to not have to have a
_CheckChanged
routine for each of the 24 checkboxes in this section of this APP call the CheckChangedWorker?
Thanks.
-- Matt
0
Answers
-
Hi Matt,
It is limitation of interpreted mode of Image-Pro scripting language, it can handle only one sender.
You can switch to Compiled mode and have full VB.NET compatibility, though you will not be able to debug your macros.
In compiled mode the following statement works:Private Sub button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button1.Click,button2.Click MsgBox(String.Format("You clicked {0}",sender.Name)) End Sub
I've also attached the test project.
Yuri0 -
2020-11-04-162030Yuri --Thank you for your guidance on this.I value having the DEBUGGER so I'll probably not use the COMPILED MODE.I was careful when I named the large group of checkbox controls. This enabled me to make 24 RESPONSE ROUTINES and one WORKER ROUTINE without not much more effort than would be required to make the HANDLES LIST for the checkboxes.Thanks again.-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions