|
-
Aug 9th, 2011, 03:45 PM
#1
Thread Starter
Lively Member
RaiseEvent - Why adding to button click raises on usercontrol load
This seems very odd to me. I need MainForm (Form) to be able to capture a user control event (btnConnect)
UserControl
Code:
Public Event ConnectionCompletedEventArgs As EventHandler
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnConnect.Click
RaiseEvent ConnectionCompletedEventArgs(Nothing, EventArgs.Empty)
End Sub
MainForm
Code:
Private WithEvents _server As New Server
Private Sub ConnectEventArghs() Handles _server.ConnectionCompletedEventArgs
Debug.WriteLine("do task here")
End Sub
should it be something like _server.btnConnection.click
-
Aug 10th, 2011, 12:44 AM
#2
Re: RaiseEvent - Why adding to button click raises on usercontrol load
First up, this:
Code:
RaiseEvent ConnectionCompletedEventArgs(Nothing, EventArgs.Empty)
should be this:
Code:
RaiseEvent ConnectionCompletedEventArgs(Me, EventArgs.Empty)
Secondly, if it's a UserControl then why are you declaring it in code when you should almost certainly be adding it to your form in the designer?
-
Aug 10th, 2011, 12:54 PM
#3
Thread Starter
Lively Member
Re: RaiseEvent - Why adding to button click raises on usercontrol load
Hi and thanks for the replys. The same issue is happening event being raised onload.
Maybe a explanation of what i am doing will allow better assistance.
I have 2 usercontrols and a mainform.
Mainform docks the user controls. When mainform loads it auto loads UC1 (UserControl1). Once options have been selected and the accept button is pressed i need MainForm to read these values, load usercontrol 2 passing this information.
am i using events wrong here?
-
Aug 10th, 2011, 02:28 PM
#4
Thread Starter
Lively Member
Re: RaiseEvent - Why adding to button click raises on usercontrol load
Opps. Managed to resolve the event error. (my own silly misstake)
but my question stands am i doing this correctly?
cheers as always VB
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
|