Custom EventHandler
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
I want to create a custom event handler for my custom control...
My control inherits from a "button", button doesn't have CheckChanged event but i want to create it.
I built up my CheckButton control but now, i want to be able to create event for it when check changes...
Please help
+ rep
My control inherits from a "button", button doesn't have CheckChanged event but i want to create it.
I built up my CheckButton control but now, i want to be able to create event for it when check changes...
Please help

I did, but how can i "Set" on what change, what to do :/ if you understand me xD
You could make a function to draw/clear a check on the button, then you could store the state as a property variable.
How do i do that 
I have this

I have this
Code: Select all
Private CheckState As Boolean
Property Checked() As Boolean
Get
Checked = CheckState
End Get
Set(ByVal value As Boolean)
CheckState = value
End Set
End Property
On CheckButton_Click, put:
Code: Select all
That way, you don't even have to have a new event, you can just make use of your current ones.If CheckState = True Then
'Do something if it is checked
CheckState = False
Else
'Do something if it isn't checked
CheckState = True
End If
I did that, and i can change the state, but i want to be able to create like in a checkbox "CheckStateChanged", because if you change its state with another button like "CheckBox1.Checked = True" nothing else will happen, and i have "color changes, style..." and many more options that are on "click" event, and not change state
So you want to be able to change the CheckState of the button from another object?
I didn't quite understand what you said. Can you rephrase it? It sounds like you want to change the state from another object.
I didn't quite understand what you said. Can you rephrase it? It sounds like you want to change the state from another object.
Here is an example :
You have 2 "CheckButtons", and a button
Button :
But my "CheckButton" handles color changes, style changes ... on "Click" event, so if you click checkbutton, everything is ok, but if you change its state from another control, only its state changes, not style,color ...
You have 2 "CheckButtons", and a button
Button :
Code: Select all
so, when you click button, CheckButtons "checked" state changes...CheckButton1.Checked = True
CheckButton2.Checked = True
But my "CheckButton" handles color changes, style changes ... on "Click" event, so if you click checkbutton, everything is ok, but if you change its state from another control, only its state changes, not style,color ...
use the RaiseEvent statement to raise an event, to declare it just use this:
Code: Select all
Public Event CheckStateChanged() 'you can have arguments between the parentheses
Code: Select all
Private CheckState As Boolean
Property Checked() As Boolean
Get
Checked = CheckState
End Get
Set(ByVal value As Boolean)
If Not value = CheckState Then RaiseEvent CheckStateChanged() 'Arguments between the parentheses
CheckState = value
End Set
End Property
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

Copyright Information
Copyright © Codenstuff.com 2020 - 2023