04-22-2014 04:08 AM
Hi
i try find a posibility to trigger an event by clicking on a checkbox. Is there a typical function/solution for a problem like that?
Thanks!!
04-22-2014 05:33 AM - edited 04-22-2014 05:34 AM
If you have the event handled, then you don't actually trigger the event, but call the event handler, so it seems like the event was triggered. Below is an example of what I mean. When the Checkbox CheckChanged event happens (or when the method is called), it'll call the method that handles the Button1.Click event as if the button was actually clicked.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'DO TASKS HERE Dim sum As Integer = 0 For i As Integer = 0 To 500 sum += i Next MessageBox.Show(sum.ToString) End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged 'CALL Button1.Click Event Handler Button1_Click(Button1, New EventArgs) End Sub
I'm just using a Button.Click event here as an example. It could be any event handler, as long as you pass the proper parameters. Hope this helps.