Form Background Image Disappears

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jcrouse

    #16
    Re: Form Background Image Disappears

    Worked great!. I had to add some logic incase the users didn't enter frm2 because then there was nothing to dispose.

    Thanks guys,
    John

    "Cor Ligthert" wrote:
    [color=blue]
    > Hi YEaHRight,
    >
    > It is almost the same code I would have showed for this.
    >
    > However one thing, why are you doing this?
    >[color=green]
    > > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
    > > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
    > > fm = Nothing
    > > End Sub
    > >[/color]
    > And not
    > fm.dispose
    >
    > A class object should in my opinon never be set to "nothing" in VB.net only
    > properties.
    >
    > Cor
    >
    >
    >[/color]

    Comment

    • Cor Ligthert

      #17
      Re: Form Background Image Disappears

      > Private Sub fm_Closing(ByVa l sender As Object, ByVal e As[color=blue]
      > System.Componen tModel.CancelEv entArgs) Handles fm.Closing
      > fm = Nothing
      > End Sub[/color]

      If it is right, that should do nothing, you are telling that there is no
      reference anymore to fm so you cannot use it anymore, however it still
      exist.

      What needs to be done is the clean up from the unmanaged resources which
      seems to be in a dialogbox, so after a frm.showdialog, there should as well
      always be a frm.dispose.

      (I am telling only what I have read, not what I have tested in this)

      Cor


      Comment

      • yEaH rIgHt

        #18
        Re: Form Background Image Disappears

        Read Page 255 in Applied Microsoft .Net Framework Programming in Microsoft
        Visual Basic .Net. By Jeffery Richter and Francesco Balena.



        "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
        news:%230nx6JvT EHA.3988@tk2msf tngp13.phx.gbl. ..[color=blue][color=green]
        > > Private Sub fm_Closing(ByVa l sender As Object, ByVal e As
        > > System.Componen tModel.CancelEv entArgs) Handles fm.Closing
        > > fm = Nothing
        > > End Sub[/color]
        >
        > If it is right, that should do nothing, you are telling that there is no
        > reference anymore to fm so you cannot use it anymore, however it still
        > exist.
        >
        > What needs to be done is the clean up from the unmanaged resources which
        > seems to be in a dialogbox, so after a frm.showdialog, there should as[/color]
        well[color=blue]
        > always be a frm.dispose.
        >
        > (I am telling only what I have read, not what I have tested in this)
        >
        > Cor
        >
        >[/color]


        Comment

        • Cor Ligthert

          #19
          Re: Form Background Image Disappears

          Hi yEaHricht,

          Intresting that it is in a book.

          However, do it as you wish, I tried only to make you attent on it.

          Cor
          [color=blue]
          > Read Page 255 in Applied Microsoft .Net Framework Programming in Microsoft
          > Visual Basic .Net. By Jeffery Richter and Francesco Balena.[/color]


          Comment

          • jcrouse

            #20
            Re: Form Background Image Disappears

            The following code works great:

            Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
            System.EventArg s) Handles Button2.Click
            If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
            Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
            Me.BackgroundIm age = bm
            End If
            End Sub

            Now, how do i remove the background Image or set it to null or nothing?

            Thanks,
            John

            "yEaH rIgHt" wrote:
            [color=blue]
            > Try these two pieces of code. This should do what you want.
            >
            >
            > '-----------In Form1
            > Option Explicit On
            > Option Strict On
            >
            > Public Class Form1
            > Inherits System.Windows. Forms.Form
            >
            >
            > Dim WithEvents fm As Form2
            >
            > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
            > System.EventArg s) Handles Button1.Click
            > If fm Is Nothing OrElse fm.IsDisposed Then
            > fm = New Form2()
            > End If
            > fm.Show()
            > Me.Hide()
            > End Sub
            >
            > Private Sub fm_VisibleChang ed(ByVal sender As Object, ByVal e As
            > System.EventArg s) Handles fm.VisibleChang ed
            > Me.Show()
            > End Sub
            >
            > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
            > System.EventArg s) Handles Button2.Click
            > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
            > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
            > Me.BackgroundIm age = bm
            > End If
            > End Sub
            >
            >
            > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
            > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
            > fm = Nothing
            > End Sub
            >
            >
            > End Class
            > '-----------End Form1
            >
            > '-----------In Form2
            >
            > Option Explicit On
            > Option Strict On
            >
            > Public Class Form2
            > Inherits System.Windows. Forms.Form
            >
            >
            > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
            > System.EventArg s) Handles Button1.Click
            > Me.Hide()
            > End Sub
            > End Class
            >
            >
            >
            >
            >
            >
            > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
            > news:17E64625-CEB0-4AD5-864F-462D616955C4@mi crosoft.com...[color=green]
            > > How do I switch back wthout creating a new instance?
            > >
            > > John
            > >
            > > "yEaH rIgHt" wrote:
            > >[color=darkred]
            > > > Did you know by using the code below you're actually creating a new[/color][/color]
            > instance[color=green][color=darkred]
            > > > of Form1? That's why the image disappears.
            > > >
            > > > I switch from form1 to form2 with this code:
            > > >
            > > > Dim frmLC as new frmLabelControl s
            > > > frmlc.Show()
            > > > Me.Hide()
            > > >
            > > > I then switch back with this code:
            > > >
            > > > '---------Creates a New Form1 WITHOUT the image!
            > > > Dim frm1 As New Form1
            > > > frm1.Show()
            > > > Me.Hide()
            > > >
            > > >
            > > >
            > > >
            > > > "jcrouse" <anonymous@disc ussions.microso ft.com> wrote in message
            > > > news:8C3F222E-4E12-4892-BE88-E07B5E18CC5D@mi crosoft.com...
            > > > > Ken,
            > > > > Here's my code:
            > > > >
            > > > > Private Sub mnuBgroundImage _Click(ByVal sender As System.Object,[/color][/color]
            > ByVal[color=green][color=darkred]
            > > > e As System.EventArg s) Handles mnuBgroundImage .Click
            > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
            > > > > Dim fs As New[/color][/color]
            > System.IO.FileS tream(OpenFileD ialog1.FileName ,[color=green][color=darkred]
            > > > IO.FileMode.Ope n)
            > > > > Dim bm As New Bitmap(fs)
            > > > > fs.Close()
            > > > > Me.BackgroundIm age = bm
            > > > > End If
            > > > > End Sub
            > > > >
            > > > > Any idea why I get an out of memory error?
            > > > >
            > > > > John
            > > >
            > > >
            > > >[/color][/color]
            >
            >
            >[/color]

            Comment

            • yEaH rIgHt

              #21
              Re: Form Background Image Disappears

              '-- Remove Image
              Me.BackgroundIm age = Nothing


              "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
              news:325E4B66-60D5-4E28-8582-7827CB9907E5@mi crosoft.com...[color=blue]
              > The following code works great:
              >
              > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
              > System.EventArg s) Handles Button2.Click
              > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
              > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
              > Me.BackgroundIm age = bm
              > End If
              > End Sub
              >
              > Now, how do i remove the background Image or set it to null or nothing?
              >
              > Thanks,
              > John
              >
              > "yEaH rIgHt" wrote:
              >[color=green]
              > > Try these two pieces of code. This should do what you want.
              > >
              > >
              > > '-----------In Form1
              > > Option Explicit On
              > > Option Strict On
              > >
              > > Public Class Form1
              > > Inherits System.Windows. Forms.Form
              > >
              > >
              > > Dim WithEvents fm As Form2
              > >
              > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
              > > System.EventArg s) Handles Button1.Click
              > > If fm Is Nothing OrElse fm.IsDisposed Then
              > > fm = New Form2()
              > > End If
              > > fm.Show()
              > > Me.Hide()
              > > End Sub
              > >
              > > Private Sub fm_VisibleChang ed(ByVal sender As Object, ByVal e As
              > > System.EventArg s) Handles fm.VisibleChang ed
              > > Me.Show()
              > > End Sub
              > >
              > > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
              > > System.EventArg s) Handles Button2.Click
              > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
              > > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
              > > Me.BackgroundIm age = bm
              > > End If
              > > End Sub
              > >
              > >
              > > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
              > > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
              > > fm = Nothing
              > > End Sub
              > >
              > >
              > > End Class
              > > '-----------End Form1
              > >
              > > '-----------In Form2
              > >
              > > Option Explicit On
              > > Option Strict On
              > >
              > > Public Class Form2
              > > Inherits System.Windows. Forms.Form
              > >
              > >
              > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
              > > System.EventArg s) Handles Button1.Click
              > > Me.Hide()
              > > End Sub
              > > End Class
              > >
              > >
              > >
              > >
              > >
              > >
              > > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
              > > news:17E64625-CEB0-4AD5-864F-462D616955C4@mi crosoft.com...[color=darkred]
              > > > How do I switch back wthout creating a new instance?
              > > >
              > > > John
              > > >
              > > > "yEaH rIgHt" wrote:
              > > >
              > > > > Did you know by using the code below you're actually creating a new[/color]
              > > instance[color=darkred]
              > > > > of Form1? That's why the image disappears.
              > > > >
              > > > > I switch from form1 to form2 with this code:
              > > > >
              > > > > Dim frmLC as new frmLabelControl s
              > > > > frmlc.Show()
              > > > > Me.Hide()
              > > > >
              > > > > I then switch back with this code:
              > > > >
              > > > > '---------Creates a New Form1 WITHOUT the image!
              > > > > Dim frm1 As New Form1
              > > > > frm1.Show()
              > > > > Me.Hide()
              > > > >
              > > > >
              > > > >
              > > > >
              > > > > "jcrouse" <anonymous@disc ussions.microso ft.com> wrote in message
              > > > > news:8C3F222E-4E12-4892-BE88-E07B5E18CC5D@mi crosoft.com...
              > > > > > Ken,
              > > > > > Here's my code:
              > > > > >
              > > > > > Private Sub mnuBgroundImage _Click(ByVal sender As[/color][/color][/color]
              System.Object,[color=blue][color=green]
              > > ByVal[color=darkred]
              > > > > e As System.EventArg s) Handles mnuBgroundImage .Click
              > > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
              > > > > > Dim fs As New[/color]
              > > System.IO.FileS tream(OpenFileD ialog1.FileName ,[color=darkred]
              > > > > IO.FileMode.Ope n)
              > > > > > Dim bm As New Bitmap(fs)
              > > > > > fs.Close()
              > > > > > Me.BackgroundIm age = bm
              > > > > > End If
              > > > > > End Sub
              > > > > >
              > > > > > Any idea why I get an out of memory error?
              > > > > >
              > > > > > John
              > > > >
              > > > >
              > > > >[/color]
              > >
              > >
              > >[/color][/color]


              Comment

              • jcrouse

                #22
                Re: Form Background Image Disappears

                Another thing. I use the following code on form2 (frmLC):

                Private Sub chkP1JoyUp_Chec kedChanged(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles chkP1JoyUp.Chec kedChanged
                If chkP1JoyUp.Chec ked = True Then
                frm1.lblP1JoyUp .Visible = True
                frm1.lblP1JoyUp .Top = (frm1.Height / 2) - (frm1.lblP1JoyU p.Height / 2)
                frm1.lblP1JoyUp .Left = (frm1.Width / 2) - (frm1.lblP1JoyU p.Width / 2)
                Else
                frm1.lblP1JoyUp .Visible = False
                frm1.lblP1JoyUp .Top = 10
                frm1.lblP1JoyUp .Left = 10
                End If
                End Sub

                If I check a checkbox it makes a label on form1 visible and moves it to the center of the form. It now seems to be broken. The label never becomes visible when I step through the code in my debugger. This happened after I change my code to your method for switching between forms (which works great). Any ideas what I'm missing here?

                Thanks,
                John

                "yEaH rIgHt" wrote:
                [color=blue]
                > Try these two pieces of code. This should do what you want.
                >
                >
                > '-----------In Form1
                > Option Explicit On
                > Option Strict On
                >
                > Public Class Form1
                > Inherits System.Windows. Forms.Form
                >
                >
                > Dim WithEvents fm As Form2
                >
                > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                > System.EventArg s) Handles Button1.Click
                > If fm Is Nothing OrElse fm.IsDisposed Then
                > fm = New Form2()
                > End If
                > fm.Show()
                > Me.Hide()
                > End Sub
                >
                > Private Sub fm_VisibleChang ed(ByVal sender As Object, ByVal e As
                > System.EventArg s) Handles fm.VisibleChang ed
                > Me.Show()
                > End Sub
                >
                > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
                > System.EventArg s) Handles Button2.Click
                > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
                > Me.BackgroundIm age = bm
                > End If
                > End Sub
                >
                >
                > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
                > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
                > fm = Nothing
                > End Sub
                >
                >
                > End Class
                > '-----------End Form1
                >
                > '-----------In Form2
                >
                > Option Explicit On
                > Option Strict On
                >
                > Public Class Form2
                > Inherits System.Windows. Forms.Form
                >
                >
                > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                > System.EventArg s) Handles Button1.Click
                > Me.Hide()
                > End Sub
                > End Class
                >
                >
                >
                >
                >
                >
                > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                > news:17E64625-CEB0-4AD5-864F-462D616955C4@mi crosoft.com...[color=green]
                > > How do I switch back wthout creating a new instance?
                > >
                > > John
                > >
                > > "yEaH rIgHt" wrote:
                > >[color=darkred]
                > > > Did you know by using the code below you're actually creating a new[/color][/color]
                > instance[color=green][color=darkred]
                > > > of Form1? That's why the image disappears.
                > > >
                > > > I switch from form1 to form2 with this code:
                > > >
                > > > Dim frmLC as new frmLabelControl s
                > > > frmlc.Show()
                > > > Me.Hide()
                > > >
                > > > I then switch back with this code:
                > > >
                > > > '---------Creates a New Form1 WITHOUT the image!
                > > > Dim frm1 As New Form1
                > > > frm1.Show()
                > > > Me.Hide()
                > > >
                > > >
                > > >
                > > >
                > > > "jcrouse" <anonymous@disc ussions.microso ft.com> wrote in message
                > > > news:8C3F222E-4E12-4892-BE88-E07B5E18CC5D@mi crosoft.com...
                > > > > Ken,
                > > > > Here's my code:
                > > > >
                > > > > Private Sub mnuBgroundImage _Click(ByVal sender As System.Object,[/color][/color]
                > ByVal[color=green][color=darkred]
                > > > e As System.EventArg s) Handles mnuBgroundImage .Click
                > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                > > > > Dim fs As New[/color][/color]
                > System.IO.FileS tream(OpenFileD ialog1.FileName ,[color=green][color=darkred]
                > > > IO.FileMode.Ope n)
                > > > > Dim bm As New Bitmap(fs)
                > > > > fs.Close()
                > > > > Me.BackgroundIm age = bm
                > > > > End If
                > > > > End Sub
                > > > >
                > > > > Any idea why I get an out of memory error?
                > > > >
                > > > > John
                > > >
                > > >
                > > >[/color][/color]
                >
                >
                >[/color]

                Comment

                • Cor Ligthert

                  #23
                  Re: Form Background Image Disappears

                  Hi John,

                  As I said in this thread, properties can set to nothing.
                  I would make this a little bit else because bitmaps seems to be expensive
                  for memory and therefore should be disposed when not used anymore.

                  I hope this is what you where looking for?

                  Cor
                  \\\
                  Private bm As Bitmap
                  Private Sub Button2_Click(B yVal sender As _
                  System.Object, ByVal e As System.EventArg s) Handles Button1.Click
                  Dim openfiledialog1 As New OpenFileDialog
                  If openfiledialog1 .ShowDialog() = DialogResult.OK Then
                  bm = New Bitmap(openfile dialog1.FileNam e)
                  Me.BackgroundIm age = bm
                  End If
                  End Sub
                  Private Sub Button3_Click(B yVal sender As System.Object, _
                  ByVal e As System.EventArg s) Handles Button2.Click
                  Me.BackgroundIm age = Nothing
                  bm.Dispose()
                  End Sub
                  ///


                  Comment

                  • yEaH rIgHt

                    #24
                    Re: Form Background Image Disappears

                    Do you have a reference to form1 in form2? You need a reference to that form
                    if you want to minipulate any of the labels.



                    "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                    news:9372F15D-C37E-42AA-A903-8B5442F55CF5@mi crosoft.com...[color=blue]
                    > Another thing. I use the following code on form2 (frmLC):
                    >
                    > Private Sub chkP1JoyUp_Chec kedChanged(ByVa l sender As System.Object,[/color]
                    ByVal e As System.EventArg s) Handles chkP1JoyUp.Chec kedChanged[color=blue]
                    > If chkP1JoyUp.Chec ked = True Then
                    > frm1.lblP1JoyUp .Visible = True
                    > frm1.lblP1JoyUp .Top = (frm1.Height / 2) -[/color]
                    (frm1.lblP1JoyU p.Height / 2)[color=blue]
                    > frm1.lblP1JoyUp .Left = (frm1.Width / 2) -[/color]
                    (frm1.lblP1JoyU p.Width / 2)[color=blue]
                    > Else
                    > frm1.lblP1JoyUp .Visible = False
                    > frm1.lblP1JoyUp .Top = 10
                    > frm1.lblP1JoyUp .Left = 10
                    > End If
                    > End Sub
                    >
                    > If I check a checkbox it makes a label on form1 visible and moves it to[/color]
                    the center of the form. It now seems to be broken. The label never becomes
                    visible when I step through the code in my debugger. This happened after I
                    change my code to your method for switching between forms (which works
                    great). Any ideas what I'm missing here?[color=blue]
                    >
                    > Thanks,
                    > John
                    >
                    > "yEaH rIgHt" wrote:
                    >[color=green]
                    > > Try these two pieces of code. This should do what you want.
                    > >
                    > >
                    > > '-----------In Form1
                    > > Option Explicit On
                    > > Option Strict On
                    > >
                    > > Public Class Form1
                    > > Inherits System.Windows. Forms.Form
                    > >
                    > >
                    > > Dim WithEvents fm As Form2
                    > >
                    > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                    > > System.EventArg s) Handles Button1.Click
                    > > If fm Is Nothing OrElse fm.IsDisposed Then
                    > > fm = New Form2()
                    > > End If
                    > > fm.Show()
                    > > Me.Hide()
                    > > End Sub
                    > >
                    > > Private Sub fm_VisibleChang ed(ByVal sender As Object, ByVal e As
                    > > System.EventArg s) Handles fm.VisibleChang ed
                    > > Me.Show()
                    > > End Sub
                    > >
                    > > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
                    > > System.EventArg s) Handles Button2.Click
                    > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                    > > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
                    > > Me.BackgroundIm age = bm
                    > > End If
                    > > End Sub
                    > >
                    > >
                    > > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
                    > > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
                    > > fm = Nothing
                    > > End Sub
                    > >
                    > >
                    > > End Class
                    > > '-----------End Form1
                    > >
                    > > '-----------In Form2
                    > >
                    > > Option Explicit On
                    > > Option Strict On
                    > >
                    > > Public Class Form2
                    > > Inherits System.Windows. Forms.Form
                    > >
                    > >
                    > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                    > > System.EventArg s) Handles Button1.Click
                    > > Me.Hide()
                    > > End Sub
                    > > End Class
                    > >
                    > >
                    > >
                    > >
                    > >
                    > >
                    > > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                    > > news:17E64625-CEB0-4AD5-864F-462D616955C4@mi crosoft.com...[color=darkred]
                    > > > How do I switch back wthout creating a new instance?
                    > > >
                    > > > John
                    > > >
                    > > > "yEaH rIgHt" wrote:
                    > > >
                    > > > > Did you know by using the code below you're actually creating a new[/color]
                    > > instance[color=darkred]
                    > > > > of Form1? That's why the image disappears.
                    > > > >
                    > > > > I switch from form1 to form2 with this code:
                    > > > >
                    > > > > Dim frmLC as new frmLabelControl s
                    > > > > frmlc.Show()
                    > > > > Me.Hide()
                    > > > >
                    > > > > I then switch back with this code:
                    > > > >
                    > > > > '---------Creates a New Form1 WITHOUT the image!
                    > > > > Dim frm1 As New Form1
                    > > > > frm1.Show()
                    > > > > Me.Hide()
                    > > > >
                    > > > >
                    > > > >
                    > > > >
                    > > > > "jcrouse" <anonymous@disc ussions.microso ft.com> wrote in message
                    > > > > news:8C3F222E-4E12-4892-BE88-E07B5E18CC5D@mi crosoft.com...
                    > > > > > Ken,
                    > > > > > Here's my code:
                    > > > > >
                    > > > > > Private Sub mnuBgroundImage _Click(ByVal sender As[/color][/color][/color]
                    System.Object,[color=blue][color=green]
                    > > ByVal[color=darkred]
                    > > > > e As System.EventArg s) Handles mnuBgroundImage .Click
                    > > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                    > > > > > Dim fs As New[/color]
                    > > System.IO.FileS tream(OpenFileD ialog1.FileName ,[color=darkred]
                    > > > > IO.FileMode.Ope n)
                    > > > > > Dim bm As New Bitmap(fs)
                    > > > > > fs.Close()
                    > > > > > Me.BackgroundIm age = bm
                    > > > > > End If
                    > > > > > End Sub
                    > > > > >
                    > > > > > Any idea why I get an out of memory error?
                    > > > > >
                    > > > > > John
                    > > > >
                    > > > >
                    > > > >[/color]
                    > >
                    > >
                    > >[/color][/color]


                    Comment

                    • news.microsoft.com

                      #25
                      Re: Form Background Image Disappears

                      I believe so. I have the following code at the top of form1:

                      Imports System
                      Imports System.IO
                      Imports System.Xml
                      Public Class Form1
                      Inherits System.Windows. Forms.Form
                      Dim mouseX As Integer
                      Dim mouseY As Integer
                      Dim _mouseDown As Boolean = False
                      Dim myMouseDown As Boolean
                      Dim WithEvents frmlc As frmLabelControl s
                      Dim bmGlobal As Bitmap

                      The next to last line should do it.

                      ????,
                      John

                      "yEaH rIgHt" <nospam@haha> wrote in message
                      news:10cguva6o0 7l401@corp.supe rnews.com...[color=blue]
                      > Do you have a reference to form1 in form2? You need a reference to that[/color]
                      form[color=blue]
                      > if you want to minipulate any of the labels.
                      >
                      >
                      >
                      > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                      > news:9372F15D-C37E-42AA-A903-8B5442F55CF5@mi crosoft.com...[color=green]
                      > > Another thing. I use the following code on form2 (frmLC):
                      > >
                      > > Private Sub chkP1JoyUp_Chec kedChanged(ByVa l sender As System.Object,[/color]
                      > ByVal e As System.EventArg s) Handles chkP1JoyUp.Chec kedChanged[color=green]
                      > > If chkP1JoyUp.Chec ked = True Then
                      > > frm1.lblP1JoyUp .Visible = True
                      > > frm1.lblP1JoyUp .Top = (frm1.Height / 2) -[/color]
                      > (frm1.lblP1JoyU p.Height / 2)[color=green]
                      > > frm1.lblP1JoyUp .Left = (frm1.Width / 2) -[/color]
                      > (frm1.lblP1JoyU p.Width / 2)[color=green]
                      > > Else
                      > > frm1.lblP1JoyUp .Visible = False
                      > > frm1.lblP1JoyUp .Top = 10
                      > > frm1.lblP1JoyUp .Left = 10
                      > > End If
                      > > End Sub
                      > >
                      > > If I check a checkbox it makes a label on form1 visible and moves it to[/color]
                      > the center of the form. It now seems to be broken. The label never becomes
                      > visible when I step through the code in my debugger. This happened after I
                      > change my code to your method for switching between forms (which works
                      > great). Any ideas what I'm missing here?[color=green]
                      > >
                      > > Thanks,
                      > > John
                      > >
                      > > "yEaH rIgHt" wrote:
                      > >[color=darkred]
                      > > > Try these two pieces of code. This should do what you want.
                      > > >
                      > > >
                      > > > '-----------In Form1
                      > > > Option Explicit On
                      > > > Option Strict On
                      > > >
                      > > > Public Class Form1
                      > > > Inherits System.Windows. Forms.Form
                      > > >
                      > > >
                      > > > Dim WithEvents fm As Form2
                      > > >
                      > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e[/color][/color][/color]
                      As[color=blue][color=green][color=darkred]
                      > > > System.EventArg s) Handles Button1.Click
                      > > > If fm Is Nothing OrElse fm.IsDisposed Then
                      > > > fm = New Form2()
                      > > > End If
                      > > > fm.Show()
                      > > > Me.Hide()
                      > > > End Sub
                      > > >
                      > > > Private Sub fm_VisibleChang ed(ByVal sender As Object, ByVal e As
                      > > > System.EventArg s) Handles fm.VisibleChang ed
                      > > > Me.Show()
                      > > > End Sub
                      > > >
                      > > > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e[/color][/color][/color]
                      As[color=blue][color=green][color=darkred]
                      > > > System.EventArg s) Handles Button2.Click
                      > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                      > > > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
                      > > > Me.BackgroundIm age = bm
                      > > > End If
                      > > > End Sub
                      > > >
                      > > >
                      > > > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
                      > > > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
                      > > > fm = Nothing
                      > > > End Sub
                      > > >
                      > > >
                      > > > End Class
                      > > > '-----------End Form1
                      > > >
                      > > > '-----------In Form2
                      > > >
                      > > > Option Explicit On
                      > > > Option Strict On
                      > > >
                      > > > Public Class Form2
                      > > > Inherits System.Windows. Forms.Form
                      > > >
                      > > >
                      > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e[/color][/color][/color]
                      As[color=blue][color=green][color=darkred]
                      > > > System.EventArg s) Handles Button1.Click
                      > > > Me.Hide()
                      > > > End Sub
                      > > > End Class
                      > > >
                      > > >
                      > > >
                      > > >
                      > > >
                      > > >
                      > > > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                      > > > news:17E64625-CEB0-4AD5-864F-462D616955C4@mi crosoft.com...
                      > > > > How do I switch back wthout creating a new instance?
                      > > > >
                      > > > > John
                      > > > >
                      > > > > "yEaH rIgHt" wrote:
                      > > > >
                      > > > > > Did you know by using the code below you're actually creating a[/color][/color][/color]
                      new[color=blue][color=green][color=darkred]
                      > > > instance
                      > > > > > of Form1? That's why the image disappears.
                      > > > > >
                      > > > > > I switch from form1 to form2 with this code:
                      > > > > >
                      > > > > > Dim frmLC as new frmLabelControl s
                      > > > > > frmlc.Show()
                      > > > > > Me.Hide()
                      > > > > >
                      > > > > > I then switch back with this code:
                      > > > > >
                      > > > > > '---------Creates a New Form1 WITHOUT the image!
                      > > > > > Dim frm1 As New Form1
                      > > > > > frm1.Show()
                      > > > > > Me.Hide()
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > > > "jcrouse" <anonymous@disc ussions.microso ft.com> wrote in message
                      > > > > > news:8C3F222E-4E12-4892-BE88-E07B5E18CC5D@mi crosoft.com...
                      > > > > > > Ken,
                      > > > > > > Here's my code:
                      > > > > > >
                      > > > > > > Private Sub mnuBgroundImage _Click(ByVal sender As[/color][/color]
                      > System.Object,[color=green][color=darkred]
                      > > > ByVal
                      > > > > > e As System.EventArg s) Handles mnuBgroundImage .Click
                      > > > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                      > > > > > > Dim fs As New
                      > > > System.IO.FileS tream(OpenFileD ialog1.FileName ,
                      > > > > > IO.FileMode.Ope n)
                      > > > > > > Dim bm As New Bitmap(fs)
                      > > > > > > fs.Close()
                      > > > > > > Me.BackgroundIm age = bm
                      > > > > > > End If
                      > > > > > > End Sub
                      > > > > > >
                      > > > > > > Any idea why I get an out of memory error?
                      > > > > > >
                      > > > > > > John
                      > > > > >
                      > > > > >
                      > > > > >
                      > > >
                      > > >
                      > > >[/color][/color]
                      >
                      >[/color]


                      Comment

                      • Cor Ligthert

                        #26
                        Re: Form Background Image Disappears

                        Hi John,

                        Again, why not using that shared class I showed you.
                        With settings things in that from form2 you can do everything in the visible
                        event from form1.

                        Cor


                        Comment

                        • jcrouse

                          #27
                          Re: Form Background Image Disappears

                          Cor...I think I found it in your earlier post. I do not understand it.
                          Again, i am a n00b. It appears to examine the checkboxes as an array? My
                          checkboxes are individual controls. I may put them in an array for
                          addressing purposes in a loop at a later time when I understand .Net 2003
                          syntax a little bit better. Right now I just want to get it working. Here is
                          the code from my test application:

                          Form 1:

                          Public Class Form1
                          Inherits System.Windows. Forms.Form
                          Dim WithEvents frm2 as Form2

                          Windows Form Designer Generated Code...

                          Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                          System.EventArg s) Handles Button1.Click

                          If frm2 Is Nothing OrElse frm2.IsDisposed Then

                          frm2 = New Form2

                          End If

                          frm2.Show()

                          Me.Hide()

                          End Sub

                          Private Sub frm2_visiblecha nged(ByVal sender As Object, ByVal e As
                          System.EventArg s) Handles frm2.VisibleCha nged

                          Me.Show()

                          End Sub



                          Private Sub frm2_Closing(By Val sender As Object, ByVal e As
                          System.Componen tModel.CancelEv entArgs) Handles frm2.Closing

                          frm2 = Nothing

                          End Sub

                          End Class

                          Public Class Checked

                          Private Shared mCheck(25) As Boolean

                          Public Shared Sub SetCheck(ByVal index As Integer, ByVal setting As
                          Boolean)

                          mCheck(index) = setting

                          End Sub

                          Public Shared Function GetCheck(ByVal index As Integer) As Boolean

                          Return mCheck(index)

                          End Function

                          End Class





                          Form 2:



                          Public Class Form2

                          Inherits System.Windows. Forms.Form

                          Dim frm1 As Form1

                          Windows Form Designer Generated Code...

                          Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                          System.EventArg s) Handles Button1.Click

                          Dim frm1 As New Form1

                          Me.Hide()

                          End Sub



                          Public Sub CheckBox1_Check edChanged(ByVal sender As System.Object, ByVal
                          e As System.EventArg s) Handles CheckBox1.Check edChanged

                          If CheckBox1.Check ed = True Then

                          CheckBox1.Check ed = Checked.GetChec k(1)

                          End If

                          End Sub

                          End Class



                          "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
                          news:OS7sBiwTEH A.156@TK2MSFTNG P12.phx.gbl...[color=blue]
                          > Hi John,
                          >
                          > Again, why not using that shared class I showed you.
                          > With settings things in that from form2 you can do everything in the[/color]
                          visible[color=blue]
                          > event from form1.
                          >
                          > Cor
                          >
                          >[/color]


                          Comment

                          • yEaH rIgHt

                            #28
                            Re: Form Background Image Disappears

                            Umm, you don't need this in Form1. Unless, of course, you created your
                            lables this way. Did you?

                            '-- You don't need this
                            Dim WithEvents frmlc As frmLabelControl s


                            You need this in form2

                            Dim frm1 as Form1

                            Public WriteOnly Property SetForm() As Form1
                            Set(ByVal Value As Form1)
                            frm1 = Value
                            End Set
                            End Property

                            Then in form1, Set the form. Like this.

                            Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                            System.EventArg s) Handles Button1.Click
                            If fm Is Nothing OrElse fm.IsDisposed Then
                            fm = New Form2()
                            fm.SetForm = Me
                            End If
                            fm.Show()
                            Me.Hide
                            End Sub




                            "news.microsoft .com" <jcrouse> wrote in message
                            news:e%2371mdwT EHA.3924@TK2MSF TNGP10.phx.gbl. ..[color=blue]
                            > I believe so. I have the following code at the top of form1:
                            >
                            > Imports System
                            > Imports System.IO
                            > Imports System.Xml
                            > Public Class Form1
                            > Inherits System.Windows. Forms.Form
                            > Dim mouseX As Integer
                            > Dim mouseY As Integer
                            > Dim _mouseDown As Boolean = False
                            > Dim myMouseDown As Boolean
                            > Dim WithEvents frmlc As frmLabelControl s
                            > Dim bmGlobal As Bitmap
                            >
                            > The next to last line should do it.
                            >
                            > ????,
                            > John
                            >
                            > "yEaH rIgHt" <nospam@haha> wrote in message
                            > news:10cguva6o0 7l401@corp.supe rnews.com...[color=green]
                            > > Do you have a reference to form1 in form2? You need a reference to that[/color]
                            > form[color=green]
                            > > if you want to minipulate any of the labels.
                            > >
                            > >
                            > >
                            > > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                            > > news:9372F15D-C37E-42AA-A903-8B5442F55CF5@mi crosoft.com...[color=darkred]
                            > > > Another thing. I use the following code on form2 (frmLC):
                            > > >
                            > > > Private Sub chkP1JoyUp_Chec kedChanged(ByVa l sender As[/color][/color][/color]
                            System.Object,[color=blue][color=green]
                            > > ByVal e As System.EventArg s) Handles chkP1JoyUp.Chec kedChanged[color=darkred]
                            > > > If chkP1JoyUp.Chec ked = True Then
                            > > > frm1.lblP1JoyUp .Visible = True
                            > > > frm1.lblP1JoyUp .Top = (frm1.Height / 2) -[/color]
                            > > (frm1.lblP1JoyU p.Height / 2)[color=darkred]
                            > > > frm1.lblP1JoyUp .Left = (frm1.Width / 2) -[/color]
                            > > (frm1.lblP1JoyU p.Width / 2)[color=darkred]
                            > > > Else
                            > > > frm1.lblP1JoyUp .Visible = False
                            > > > frm1.lblP1JoyUp .Top = 10
                            > > > frm1.lblP1JoyUp .Left = 10
                            > > > End If
                            > > > End Sub
                            > > >
                            > > > If I check a checkbox it makes a label on form1 visible and moves it[/color][/color][/color]
                            to[color=blue][color=green]
                            > > the center of the form. It now seems to be broken. The label never[/color][/color]
                            becomes[color=blue][color=green]
                            > > visible when I step through the code in my debugger. This happened after[/color][/color]
                            I[color=blue][color=green]
                            > > change my code to your method for switching between forms (which works
                            > > great). Any ideas what I'm missing here?[color=darkred]
                            > > >
                            > > > Thanks,
                            > > > John
                            > > >
                            > > > "yEaH rIgHt" wrote:
                            > > >
                            > > > > Try these two pieces of code. This should do what you want.
                            > > > >
                            > > > >
                            > > > > '-----------In Form1
                            > > > > Option Explicit On
                            > > > > Option Strict On
                            > > > >
                            > > > > Public Class Form1
                            > > > > Inherits System.Windows. Forms.Form
                            > > > >
                            > > > >
                            > > > > Dim WithEvents fm As Form2
                            > > > >
                            > > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e[/color][/color]
                            > As[color=green][color=darkred]
                            > > > > System.EventArg s) Handles Button1.Click
                            > > > > If fm Is Nothing OrElse fm.IsDisposed Then
                            > > > > fm = New Form2()
                            > > > > End If
                            > > > > fm.Show()
                            > > > > Me.Hide()
                            > > > > End Sub
                            > > > >
                            > > > > Private Sub fm_VisibleChang ed(ByVal sender As Object, ByVal e As
                            > > > > System.EventArg s) Handles fm.VisibleChang ed
                            > > > > Me.Show()
                            > > > > End Sub
                            > > > >
                            > > > > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e[/color][/color]
                            > As[color=green][color=darkred]
                            > > > > System.EventArg s) Handles Button2.Click
                            > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                            > > > > Dim bm As New Bitmap(OpenFile Dialog1.FileNam e)
                            > > > > Me.BackgroundIm age = bm
                            > > > > End If
                            > > > > End Sub
                            > > > >
                            > > > >
                            > > > > Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
                            > > > > System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
                            > > > > fm = Nothing
                            > > > > End Sub
                            > > > >
                            > > > >
                            > > > > End Class
                            > > > > '-----------End Form1
                            > > > >
                            > > > > '-----------In Form2
                            > > > >
                            > > > > Option Explicit On
                            > > > > Option Strict On
                            > > > >
                            > > > > Public Class Form2
                            > > > > Inherits System.Windows. Forms.Form
                            > > > >
                            > > > >
                            > > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e[/color][/color]
                            > As[color=green][color=darkred]
                            > > > > System.EventArg s) Handles Button1.Click
                            > > > > Me.Hide()
                            > > > > End Sub
                            > > > > End Class
                            > > > >
                            > > > >
                            > > > >
                            > > > >
                            > > > >
                            > > > >
                            > > > > "jcrouse" <jcrouse@discus sions.microsoft .com> wrote in message
                            > > > > news:17E64625-CEB0-4AD5-864F-462D616955C4@mi crosoft.com...
                            > > > > > How do I switch back wthout creating a new instance?
                            > > > > >
                            > > > > > John
                            > > > > >
                            > > > > > "yEaH rIgHt" wrote:
                            > > > > >
                            > > > > > > Did you know by using the code below you're actually creating a[/color][/color]
                            > new[color=green][color=darkred]
                            > > > > instance
                            > > > > > > of Form1? That's why the image disappears.
                            > > > > > >
                            > > > > > > I switch from form1 to form2 with this code:
                            > > > > > >
                            > > > > > > Dim frmLC as new frmLabelControl s
                            > > > > > > frmlc.Show()
                            > > > > > > Me.Hide()
                            > > > > > >
                            > > > > > > I then switch back with this code:
                            > > > > > >
                            > > > > > > '---------Creates a New Form1 WITHOUT the image!
                            > > > > > > Dim frm1 As New Form1
                            > > > > > > frm1.Show()
                            > > > > > > Me.Hide()
                            > > > > > >
                            > > > > > >
                            > > > > > >
                            > > > > > >
                            > > > > > > "jcrouse" <anonymous@disc ussions.microso ft.com> wrote in message
                            > > > > > > news:8C3F222E-4E12-4892-BE88-E07B5E18CC5D@mi crosoft.com...
                            > > > > > > > Ken,
                            > > > > > > > Here's my code:
                            > > > > > > >
                            > > > > > > > Private Sub mnuBgroundImage _Click(ByVal sender As[/color]
                            > > System.Object,[color=darkred]
                            > > > > ByVal
                            > > > > > > e As System.EventArg s) Handles mnuBgroundImage .Click
                            > > > > > > > If OpenFileDialog1 .ShowDialog() = DialogResult.OK Then
                            > > > > > > > Dim fs As New
                            > > > > System.IO.FileS tream(OpenFileD ialog1.FileName ,
                            > > > > > > IO.FileMode.Ope n)
                            > > > > > > > Dim bm As New Bitmap(fs)
                            > > > > > > > fs.Close()
                            > > > > > > > Me.BackgroundIm age = bm
                            > > > > > > > End If
                            > > > > > > > End Sub
                            > > > > > > >
                            > > > > > > > Any idea why I get an out of memory error?
                            > > > > > > >
                            > > > > > > > John
                            > > > > > >
                            > > > > > >
                            > > > > > >
                            > > > >
                            > > > >
                            > > > >[/color]
                            > >
                            > >[/color]
                            >
                            >[/color]


                            Comment

                            • yEaH rIgHt

                              #29
                              Re: Form Background Image Disappears

                              Remove the Dim frm1 As New Form1 in the Button click event in form2. You
                              created a new Form1 with that code. Why?



                              "jcrouse" <me> wrote in message
                              news:en2zL5wTEH A.1508@TK2MSFTN GP11.phx.gbl...[color=blue]
                              > Cor...I think I found it in your earlier post. I do not understand it.
                              > Again, i am a n00b. It appears to examine the checkboxes as an array? My
                              > checkboxes are individual controls. I may put them in an array for
                              > addressing purposes in a loop at a later time when I understand .Net 2003
                              > syntax a little bit better. Right now I just want to get it working. Here[/color]
                              is[color=blue]
                              > the code from my test application:
                              >
                              > Form 1:
                              >
                              > Public Class Form1
                              > Inherits System.Windows. Forms.Form
                              > Dim WithEvents frm2 as Form2
                              >
                              > Windows Form Designer Generated Code...
                              >
                              > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                              > System.EventArg s) Handles Button1.Click
                              >
                              > If frm2 Is Nothing OrElse frm2.IsDisposed Then
                              >
                              > frm2 = New Form2
                              >
                              > End If
                              >
                              > frm2.Show()
                              >
                              > Me.Hide()
                              >
                              > End Sub
                              >
                              > Private Sub frm2_visiblecha nged(ByVal sender As Object, ByVal e As
                              > System.EventArg s) Handles frm2.VisibleCha nged
                              >
                              > Me.Show()
                              >
                              > End Sub
                              >
                              >
                              >
                              > Private Sub frm2_Closing(By Val sender As Object, ByVal e As
                              > System.Componen tModel.CancelEv entArgs) Handles frm2.Closing
                              >
                              > frm2 = Nothing
                              >
                              > End Sub
                              >
                              > End Class
                              >
                              > Public Class Checked
                              >
                              > Private Shared mCheck(25) As Boolean
                              >
                              > Public Shared Sub SetCheck(ByVal index As Integer, ByVal setting As
                              > Boolean)
                              >
                              > mCheck(index) = setting
                              >
                              > End Sub
                              >
                              > Public Shared Function GetCheck(ByVal index As Integer) As Boolean
                              >
                              > Return mCheck(index)
                              >
                              > End Function
                              >
                              > End Class
                              >
                              >
                              >
                              >
                              >
                              > Form 2:
                              >
                              >
                              >
                              > Public Class Form2
                              >
                              > Inherits System.Windows. Forms.Form
                              >
                              > Dim frm1 As Form1
                              >
                              > Windows Form Designer Generated Code...
                              >
                              > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                              > System.EventArg s) Handles Button1.Click
                              >
                              > Dim frm1 As New Form1
                              >
                              > Me.Hide()
                              >
                              > End Sub
                              >
                              >
                              >
                              > Public Sub CheckBox1_Check edChanged(ByVal sender As System.Object,[/color]
                              ByVal[color=blue]
                              > e As System.EventArg s) Handles CheckBox1.Check edChanged
                              >
                              > If CheckBox1.Check ed = True Then
                              >
                              > CheckBox1.Check ed = Checked.GetChec k(1)
                              >
                              > End If
                              >
                              > End Sub
                              >
                              > End Class
                              >
                              >
                              >
                              > "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
                              > news:OS7sBiwTEH A.156@TK2MSFTNG P12.phx.gbl...[color=green]
                              > > Hi John,
                              > >
                              > > Again, why not using that shared class I showed you.
                              > > With settings things in that from form2 you can do everything in the[/color]
                              > visible[color=green]
                              > > event from form1.
                              > >
                              > > Cor
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              • jcrouse

                                #30
                                Re: Form Background Image Disappears

                                The only place that string appears in Form2 is here:

                                Public Class frmLabelControl s
                                Inherits System.Windows. Forms.Form
                                Dim frm1 as New Form1

                                I am suspecting the code you are looking at has since been changed. Please
                                see the other post for the code from my test app.

                                Thank you for your help,
                                John



                                "yEaH rIgHt" <nospam@haha> wrote in message
                                news:10ch6g275s 7r0e1@corp.supe rnews.com...[color=blue]
                                > Remove the Dim frm1 As New Form1 in the Button click event in form2. You
                                > created a new Form1 with that code. Why?
                                >
                                >
                                >
                                > "jcrouse" <me> wrote in message
                                > news:en2zL5wTEH A.1508@TK2MSFTN GP11.phx.gbl...[color=green]
                                > > Cor...I think I found it in your earlier post. I do not understand it.
                                > > Again, i am a n00b. It appears to examine the checkboxes as an array? My
                                > > checkboxes are individual controls. I may put them in an array for
                                > > addressing purposes in a loop at a later time when I understand .Net[/color][/color]
                                2003[color=blue][color=green]
                                > > syntax a little bit better. Right now I just want to get it working.[/color][/color]
                                Here[color=blue]
                                > is[color=green]
                                > > the code from my test application:
                                > >
                                > > Form 1:
                                > >
                                > > Public Class Form1
                                > > Inherits System.Windows. Forms.Form
                                > > Dim WithEvents frm2 as Form2
                                > >
                                > > Windows Form Designer Generated Code...
                                > >
                                > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                                > > System.EventArg s) Handles Button1.Click
                                > >
                                > > If frm2 Is Nothing OrElse frm2.IsDisposed Then
                                > >
                                > > frm2 = New Form2
                                > >
                                > > End If
                                > >
                                > > frm2.Show()
                                > >
                                > > Me.Hide()
                                > >
                                > > End Sub
                                > >
                                > > Private Sub frm2_visiblecha nged(ByVal sender As Object, ByVal e As
                                > > System.EventArg s) Handles frm2.VisibleCha nged
                                > >
                                > > Me.Show()
                                > >
                                > > End Sub
                                > >
                                > >
                                > >
                                > > Private Sub frm2_Closing(By Val sender As Object, ByVal e As
                                > > System.Componen tModel.CancelEv entArgs) Handles frm2.Closing
                                > >
                                > > frm2 = Nothing
                                > >
                                > > End Sub
                                > >
                                > > End Class
                                > >
                                > > Public Class Checked
                                > >
                                > > Private Shared mCheck(25) As Boolean
                                > >
                                > > Public Shared Sub SetCheck(ByVal index As Integer, ByVal setting As
                                > > Boolean)
                                > >
                                > > mCheck(index) = setting
                                > >
                                > > End Sub
                                > >
                                > > Public Shared Function GetCheck(ByVal index As Integer) As Boolean
                                > >
                                > > Return mCheck(index)
                                > >
                                > > End Function
                                > >
                                > > End Class
                                > >
                                > >
                                > >
                                > >
                                > >
                                > > Form 2:
                                > >
                                > >
                                > >
                                > > Public Class Form2
                                > >
                                > > Inherits System.Windows. Forms.Form
                                > >
                                > > Dim frm1 As Form1
                                > >
                                > > Windows Form Designer Generated Code...
                                > >
                                > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                                > > System.EventArg s) Handles Button1.Click
                                > >
                                > > Dim frm1 As New Form1
                                > >
                                > > Me.Hide()
                                > >
                                > > End Sub
                                > >
                                > >
                                > >
                                > > Public Sub CheckBox1_Check edChanged(ByVal sender As System.Object,[/color]
                                > ByVal[color=green]
                                > > e As System.EventArg s) Handles CheckBox1.Check edChanged
                                > >
                                > > If CheckBox1.Check ed = True Then
                                > >
                                > > CheckBox1.Check ed = Checked.GetChec k(1)
                                > >
                                > > End If
                                > >
                                > > End Sub
                                > >
                                > > End Class
                                > >
                                > >
                                > >
                                > > "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
                                > > news:OS7sBiwTEH A.156@TK2MSFTNG P12.phx.gbl...[color=darkred]
                                > > > Hi John,
                                > > >
                                > > > Again, why not using that shared class I showed you.
                                > > > With settings things in that from form2 you can do everything in the[/color]
                                > > visible[color=darkred]
                                > > > event from form1.
                                > > >
                                > > > Cor
                                > > >
                                > > >[/color]
                                > >
                                > >[/color]
                                >
                                >[/color]


                                Comment

                                Working...