|
-
Feb 24th, 2003, 05:45 AM
#1
Thread Starter
New Member
Usercontrol Question
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
Last edited by NETY; Feb 24th, 2003 at 10:37 AM.
-
Feb 24th, 2003, 08:25 PM
#2
Member
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...
-
Feb 24th, 2003, 08:29 PM
#3
Member
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.
-
Mar 4th, 2003, 01:40 PM
#4
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|