我正在用VB做一个项目。Net使用各种动态创建的面板,这些面板具有动态创建的表单元素,这些元素随着屏幕大小的调整而动态调整大小。为了避免为所有类似元素重复数千行代码,我创建了以下设置:
Public Class PanelComponents
Dim componentsList As New List(Of PanelComponent)
'Methods etc here
Private MustInherit Class PanelComponent
'Method data here
End Class
Private Class ComboBoxComponent
Inherits PanelComponent
'Method data here
End Class
'More Children of PanelComponent
End Class
在大多数情况下,这对我的程序的执行来说是非常好的,但是我目前遇到了一个障碍。在我现在正在进行的程序中,我希望能够在其中一个应用程序中添加一个事件
ComboBoxComponent
对象,而不在
PanelComponents
班我希望这样,当用户更改组合框的选定索引时,它会触发一个方法,该方法会根据选择的更改修改一些代码变量。
但是因为我的
ComboBoxComponent
是嵌套在我的
面板组件
类我不确定如何将事件处理程序添加到或(或如何为
Handles
电话)。