How can I process events from controls add dynmically?
VBControlExtender can only handle non-intrinsic controls,
so what is with the standard ones?
thanks
Printable View
How can I process events from controls add dynmically?
VBControlExtender can only handle non-intrinsic controls,
so what is with the standard ones?
thanks
Are you loading controls as a control array?
if so use the index of the control
is this the sort of thing you mean?
Code:Private Sub Command2_Click(Index As Integer)
Select Case Index
Case 0
Debug.Print "Command2(0) was pressed"
Case 1
Debug.Print "Command2(1) was pressed"
Case 2
Debug.Print "Command2(2) was pressed"
End Select
End Sub
It is actually more complicated:
I have forms in a project representing dialogs and I have a
main form supposed to contain those dialogs.
I copy the controls of these dialog forms into the main
window by using frames as container for hiding and unhiding.
Fact is, I have at designtime no idea of any controls in
the main form, but I want to react on their events of
course.
???
You can declare objects for each of the control type like:
Dim WithEvents MyTextBox As TextBox
Now, even though MyTextBox is an object used in the code, since we are using WithEvents, this object can contain all events of a text box, like you can have:
Private Sub MyTextBox_Click()
Private Sub MyTextBox_Change()
and so on. You can define all events for a textbox into the events of MyTextBox. Then in the application, use the ActiveControl property of the form to retrieve the active control on it. Set the MyTextBox object to that control and your MyTextBox event will get executed for that control.
Note one thing: In the above para, I am assuming that your control is a text box. If it is a different type of control you can declare another object of that type.
Hope it helps.