DjJohnny
asked on
AddHandler "Is not an event of object"
Hi Experts.
I have a form that opens as a control of a panel.
Private Sub OpenfrmTakeOffSubWalls(ByV al Edited As Boolean)
Dim SubFrm = New frmTakeOffSubWalls
With SubFrm
.TopLevel = False
.Dock = DockStyle.Fill
.Anchor = AnchorStyles.Bottom
.WindowState = FormWindowState.Maximized
Me.Panel1.Controls.Add(Sub Frm)
AddHandler SubFrm.UpdateTakeOffGrid, AddressOf FillTakeOffGrid
.Show()
End With
End Sub
works well. When I move the " Dim SubFrm = New frmTakeOffSubWalls" to the top of the form:
Public Class frmTakeOff
Dim SubFrm = New frmTakeOffSubWalls
I then get an error frmTakeOffSubWalls is not an event of "object"
The reason I moved the declaration to the top is I need to refer to the form later on a click event of the subform.
Thank you
John
I have a form that opens as a control of a panel.
Private Sub OpenfrmTakeOffSubWalls(ByV
Dim SubFrm = New frmTakeOffSubWalls
With SubFrm
.TopLevel = False
.Dock = DockStyle.Fill
.Anchor = AnchorStyles.Bottom
.WindowState = FormWindowState.Maximized
Me.Panel1.Controls.Add(Sub
AddHandler SubFrm.UpdateTakeOffGrid, AddressOf FillTakeOffGrid
.Show()
End With
End Sub
works well. When I move the " Dim SubFrm = New frmTakeOffSubWalls" to the top of the form:
Public Class frmTakeOff
Dim SubFrm = New frmTakeOffSubWalls
I then get an error frmTakeOffSubWalls is not an event of "object"
The reason I moved the declaration to the top is I need to refer to the form later on a click event of the subform.
Thank you
John
ASKER
Thank you VBRocks,
Public Class frmTakeOffSubWalls
Dim CurrentTakeOffId As Integer
Dim CurrentRevisionId As Integer
Public CurrentTakeOffItemId As Integer
Dim FormHasChanged As Boolean
Public EditMode As Boolean
Public Event UpdateTakeOffGrid()
and
Private Sub FillTakeOffGrid()
Try
Me.TakeOffItemsTableAdapte r.Fill(Me. DsTakeOff. TakeOffIte ms, CurrentTakeOffId, CurrentRevisionNumber)
Me.TakeOffItemsMaterialTab leAdapter. Fill(Me.Ds TakeOff.Ta keOffItems Material, CurrentTakeOffId)
ExpandTakeOffGrid()
Catch ex As System.Exception
System.Windows.Forms.Messa geBox.Show (ex.Messag e)
End Try
End Sub
Public Class frmTakeOffSubWalls
Dim CurrentTakeOffId As Integer
Dim CurrentRevisionId As Integer
Public CurrentTakeOffItemId As Integer
Dim FormHasChanged As Boolean
Public EditMode As Boolean
Public Event UpdateTakeOffGrid()
and
Private Sub FillTakeOffGrid()
Try
Me.TakeOffItemsTableAdapte
Me.TakeOffItemsMaterialTab
ExpandTakeOffGrid()
Catch ex As System.Exception
System.Windows.Forms.Messa
End Try
End Sub
Well, 2 things you can try:
First, declare FillTakeOffGrid as Public.
Second, Change your event declaration as follows:
Public Event UpdateTakeOffGrid(ByVal sender As Object, ByVal e As EventArgs)
Then, update the FillTakeOffGrid method signature to match the event declaration:
Public Sub FillTakeOffGrid(ByVal sender As Object, ByVal e As EventArgs)
Try those and see if that works for you.
First, declare FillTakeOffGrid as Public.
Second, Change your event declaration as follows:
Public Event UpdateTakeOffGrid(ByVal sender As Object, ByVal e As EventArgs)
Then, update the FillTakeOffGrid method signature to match the event declaration:
Public Sub FillTakeOffGrid(ByVal sender As Object, ByVal e As EventArgs)
Try those and see if that works for you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, duh... Good catch Idle_Mind.
Also post the declaration for "FillTakeOffGrid".
Thanks.