ich habe dem Control ein Event hinzugefügt, wo mit CheckedChanged ausgewertet werden kann
Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
#Region "CheckboxToolboxItem"
'Wrapperklasse zum Aufnehmen der Checkbox
'Checkbox im Designer verfügbar machen und Icon zuweisen
<ToolboxItem(GetType(CheckboxToolboxItem)), _
ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All), _
ToolboxBitmap(GetType(CheckBox))> _
Public Class ToolStripCheckbox
Inherits ToolStripControlHost
Public Sub New()
MyBase.New(New CheckBox())
MyBase.BackColor = Color.Transparent
End Sub
'Events im Control verfügbar machen
Protected Overrides Sub OnSubscribeControlEvents(ByVal c As Control)
MyBase.OnSubscribeControlEvents(c)
Dim checkboxControl As CheckBox = CType(c, CheckBox)
AddHandler checkboxControl.CheckedChanged, AddressOf _
HandleCheckedChanged
End Sub
Protected Overrides Sub OnUnsubscribeControlEvents(ByVal c As Control)
MyBase.OnUnsubscribeControlEvents(c)
Dim checkboxControl As CheckBox = CType(c, CheckBox)
RemoveHandler checkboxControl.CheckedChanged, AddressOf _
HandleCheckedChanged
End Sub
'Event hinzufügen
Public Event CheckedChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs)
Private Sub HandleCheckedChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs)
RaiseEvent CheckedChanged(Me, e)
End Sub
End Class
'Checkbox als neue ToolboxItem bereitstellen
Public Class CheckboxToolboxItem
Inherits ToolboxItem
Public Sub New()
End Sub
Public Overrides Sub Initialize(ByVal type As Type)
MyBase.Initialize(type)
Me.Description = "ToolstripCheckbox"
Me.DisplayName = "Checkbox"
End Sub
End Class
#End Region
#Region "RadioButtonToolboxItem"
<ToolboxItem(GetType(RadioButtonToolboxItem)), _
ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All), _
ToolboxBitmap(GetType(RadioButton))> _
Public Class ToolStripRadioButton
Inherits ToolStripControlHost
Public Sub New()
MyBase.New(New RadioButton())
MyBase.BackColor = Color.Transparent
End Sub
Protected Overrides Sub OnSubscribeControlEvents(ByVal c As Control)
MyBase.OnSubscribeControlEvents(c)
Dim RadiobuttonControl As RadioButton = CType(c, RadioButton)
AddHandler RadiobuttonControl.CheckedChanged, AddressOf _
HandleCheckedChanged
End Sub
Protected Overrides Sub OnUnsubscribeControlEvents(ByVal c As Control)
MyBase.OnUnsubscribeControlEvents(c)
Dim RadiobuttonControl As RadioButton = CType(c, RadioButton)
RemoveHandler RadioButtonControl.CheckedChanged, AddressOf _
HandleCheckedChanged
End Sub
Public Event CheckedChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs)
Private Sub HandleCheckedChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs)
RaiseEvent CheckedChanged(Me, e)
End Sub
End Class
Public Class RadioButtonToolboxItem
Inherits System.Drawing.Design.ToolboxItem
Public Sub New()
End Sub
Public Overrides Sub Initialize(ByVal type As Type)
MyBase.Initialize(type)
Me.Description = "ToolstripRadioButton"
Me.DisplayName = "RadioButton"
End Sub
End Class
#End Region peppi78 |