我正在尝试在应用程序中创建多个自定义控件,例如:
Public Class CbsDataGridView
Inherits DataGridView
'...
Private Sub CbsDataGridView_Enter(sender As Object, e As EventArgs) Handles MyBase.Enter
'Code here omitted, not related to the question.
LoadGrid()
End Sub
Private Sub LoadGrid()
'Code here omitted, not related to the question.
End Sub
'...
End Class
Public Class CbsDateTimePicker
Inherits DateTimePicker
Private Sub CbsDateTimePicker_Enter(sender As Object, e As EventArgs) Handles MyBase.Enter
'Code here omitted, not related to the question.
End Sub
End Class
将这些控件添加到新的空表单时。以下是我面临的两种情况:
场景1:
- Drag And Drop CbsDateTimePicker into the form
- Drag And Drop CbsDataGridView into the form
- Run Application - Load The New Form
- CbsDateTimePicker_Enter event fires.
- CbsDataGridView_Enter event doesn't fire.
场景2:
- Drag And Drop CbsDataGridView into the form
- Drag And Drop CbsDateTimePicker into the form
- Run Application - Load The New Form
- CbsDataGridView_Enter event fires.
- CbsDateTimePicker_Enter event doesn't fire.
我想我错过了
Enter
控制事件。
我要找的是一个像
Form.Load
包含控件的窗体加载时将激发的事件。
是否有直接的方法来实现此功能?还是我应该寻找另一种方式?