I am having trouble getting one usercontrol to remove and adding another usercontrol onto my main form. This was working like it was intended just last week I have included the code for the main form "frmMain" and the code from the report Search usercontrol "ucReportSearch". The code fails when it reaches the RemovePanel in the AddReportContainer procedure. For some reason it is not recognizing my local vaiable ItemPanel in the RemovePanel. Instead of displaying the reference object objReportContainer it will display ReportTrackermMaster.objReportContainer when I do a step-through during debugging. Not sure why this is happening.
frmMain
Im not sure if this is the root care to my problem when application executes frmMain.AddReportContainer
this is where the trouble begins.
objReportSearch
Your assistance is greatly needed and thanks in advance.
Paul
paul_wilson74@hotmail.com
frmMain
Code:
[COLOR=blue]Public Class[/color] frmMain
[COLOR=green]' Declare refernce to User Control[/color]
[COLOR=blue]Private WithEvents[/color] objReportContainer [COLOR=blue]As[/color] ucReportContainer
[COLOR=green]' Declare local variable to store the current User Control[/color]
[COLOR=blue]Dim[/color] ItemPanel [COLOR=blue]As[/color] Control
[COLOR=blue]Public Sub[/color] AddReportContainer()
RemovePanel()
objReportContainer = [COLOR=blue]New[/color]ucReportContainer
pnlMain.Controls.Add(objReortContainer)
objReportContainer.Dock = DockStyle.Fill
[COLOR=green]'Set the current User Control to the control variable[/color]
ItemPanel = objReportContainer
[COLOR=blue]End Sub[/color]
[COLOR=blue]Private Sub[/color] RemovePanel()
[COLOR=green]'Remove the panel if it is the current panel[/color]
[COLOR=blue]If Not[/color] IsNothing(ItemPanel) [COLOR=blue]Then[/color]
ItemPanel.Dock = DockStyle.None
pnlMain.Controls.Remove(ItemPanel)
[COLOR=blue]End Sub[/color]
[COLOR=blue]End Class[/color]
Im not sure if this is the root care to my problem when application executes frmMain.AddReportContainer
this is where the trouble begins.
objReportSearch
Code:
[COLOR=blue]Private Sub[/color] lvList_DoubleClick([COLOR=blue]ByVal[/color] sender [COLOR=blue]As[/color] System.Object, [COLOR=blue]ByVal[/color] e [COLOR=blue]As[/color] System.EventArgs) [COLOR=blue]Handles[/color] lvList.DoubleClick
[COLOR=blue]My[/color].Settings.gReportID = lvList.SelectedItems.Item(0).Tab
frmMain.AddReportContainer()
[COLOR=blue]End Sub[/color]
Your assistance is greatly needed and thanks in advance.
Paul
paul_wilson74@hotmail.com