VB.NET - to initialize one form in more than one instance

Asked By abinav shankar on 19-Sep-11 01:55 AM

hi

i have a form which is used as a proces log in which the user can know what process is actually running for this i have created a form called processlog and initialized the form in another form called frmmain and got the values but i have to initialize the form process log to another form called frmpublish how to initialize the same form in more than one form such that the values will be maintained correctly

Tom Wilson replied to abinav shankar on 19-Sep-11 09:16 AM
One option is to pass the instance of the processlog form to all forms that may need to use it.  Create the instance of the processlog form in the first form that needs to use the processlog form.

'frmMain
'someevent
Dim prclog as new ProcessLog
'Another Event
Dim frm as new frmpublish(prclog)


'frmpublish
Private prclog as ProcessLog
Public Sub New(byval frm as ProcessLog)
     InitializeComponent()
   prclopg = frm
End Sub

'some event that requires the processlog form --  Check to see if an instance of ProcessLog exists, if not create it
If prclog is nothing then
   prclog = new Processlog
End if