Hi all,
on my usercontrol i have some Textboxes and one Button.
1. How can I have all the events from the Controls in the main Form?
For example the "Button_Click" Event
2. How can I access Controls from the MainForm in my Usercontrol?
THX
Greetings
Printable View
Hi all,
on my usercontrol i have some Textboxes and one Button.
1. How can I have all the events from the Controls in the main Form?
For example the "Button_Click" Event
2. How can I access Controls from the MainForm in my Usercontrol?
THX
Greetings
You can try to declare your textbox/button in the control as public and at the main form which using this control, try to use the ADDHANDLER method to assign the control's button/textbox event to a particular Sub declare at your main form. I suppose this should work, but i haven't try before... perhaps after my office hour i will try to work out and see. by the time being hopefully this would give you some idea on how to do it...
Another way to do this is your declare a Public event for your control... then at the button_click event, try to fire this custom event. For example:
Public Event MybuttonClick()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent MybuttonClick()
End Sub
the custom event MybuttonClick should be visible at the main form souce code editor whenver you using your usercontrol.
Hi StormJason,
thanks a lot for your Replys.
I have decleared the controls as public.
Is this the professional way, because for every event i want to use in my mainform , I must add new events ?! For example. The Button-Control has a lot of such events.
THX
NETY