PictureBox created in code not working

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

    PictureBox created in code not working

    XP VB 2005 running an example from help that creates a picturebox in
    code - the picturebox is not created.
    If I comment out the "Dim Box as New PictureBox" and create it in
    Design mode - the example works.
    I have tried Show, Enabled, Visible, and even BackColor.
    Why does a help example not work? and why does Design creation work?
    Thanks - I hope.
  • kimiraikkonen

    #2
    Re: PictureBox created in code not working

    On Nov 13, 9:41 pm, AWW <wrote:
    XP VB 2005 running an example from help that creates a picturebox in
    code - the picturebox is not created.
     If I comment out the "Dim Box as New PictureBox" and create it in
    Design mode - the example works.
    I have tried Show, Enabled, Visible, and even BackColor.
    Why does a help example not work? and why does Design creation work?
    Thanks - I hope.
    It's not much clear what you mean, but as far as i understand, you
    don't see picturebox on your form, and i think that's because you
    didn't add picturebox control on your form by calling "Me.Controls.Ad d
    (Box)" and also you need to specify the location of your picturebox
    based on your example which you didn't tell its code.

    So, try this with assumption:

    Dim Box As New PictureBox
    Box.Image = Image.FromFile( "c:\picture.jpg ")
    Box.Location = New Point(100, 100)
    ' Equalize picturebox size with image size
    Box.Size = Box.Image.Size

    ' Finally add control onto form
    Me.Controls.Add (Box)

    Hope this helps,

    Onur Güzel

    Comment

    • AWW

      #3
      Re: PictureBox created in code not working

      On Thu, 13 Nov 2008 12:56:30 -0800 (PST), kimiraikkonen
      <kimiraikkonen8 5@gmail.comwrot e:
      >On Nov 13, 9:41 pm, AWW <wrote:
      >XP VB 2005 running an example from help that creates a picturebox in
      >code - the picturebox is not created.
      > If I comment out the "Dim Box as New PictureBox" and create it in
      >Design mode - the example works.
      >I have tried Show, Enabled, Visible, and even BackColor.
      >Why does a help example not work? and why does Design creation work?
      >Thanks - I hope.
      >
      >It's not much clear what you mean, but as far as i understand, you
      >don't see picturebox on your form, and i think that's because you
      >didn't add picturebox control on your form by calling "Me.Controls.Ad d
      >(Box)" and also you need to specify the location of your picturebox
      >based on your example which you didn't tell its code.
      >
      >So, try this with assumption:
      >
      >Dim Box As New PictureBox
      >Box.Image = Image.FromFile( "c:\picture.jpg ")
      >Box.Location = New Point(100, 100)
      >' Equalize picturebox size with image size
      >Box.Size = Box.Image.Size
      >
      >' Finally add control onto form
      >Me.Controls.Ad d(Box)
      >
      I am using an example from Help showing how to draw a line in a
      PictureBox - so no image involved - and it did not work until I
      replaced "Dim Box as New PictureBox" with a box created in Design
      mode. Is that clear. Yes the "Me.Controls.Ad d(Box)" is there.
      Basically the question is - how to create a New PictureBox in code -
      not containing an image - the same way as a PictureBox is created in
      Design mode. Or is that not possible? Thanks.
      >Hope this helps,
      >
      >Onur Güzel

      Comment

      • AWW

        #4
        Re: PictureBox created in code not working

        On Thu, 13 Nov 2008 12:56:30 -0800 (PST), kimiraikkonen
        <kimiraikkonen8 5@gmail.comwrot e:
        >On Nov 13, 9:41 pm, AWW <wrote:
        >XP VB 2005 running an example from help that creates a picturebox in
        >code - the picturebox is not created.
        > If I comment out the "Dim Box as New PictureBox" and create it in
        >Design mode - the example works.
        >I have tried Show, Enabled, Visible, and even BackColor.
        >Why does a help example not work? and why does Design creation work?
        >Thanks - I hope.
        >
        >It's not much clear what you mean, but as far as i understand, you
        >don't see picturebox on your form, and i think that's because you
        >didn't add picturebox control on your form by calling "Me.Controls.Ad d
        >(Box)" and also you need to specify the location of your picturebox
        >based on your example which you didn't tell its code.
        >
        >So, try this with assumption:
        >
        >Dim Box As New PictureBox
        >Box.Image = Image.FromFile( "c:\picture.jpg ")
        >Box.Location = New Point(100, 100)
        >' Equalize picturebox size with image size
        >Box.Size = Box.Image.Size
        >
        >' Finally add control onto form
        >Me.Controls.Ad d(Box)
        >
        >Hope this helps,
        >
        >Onur Güzel
        I said that I had "Me.Controls.Ad d(Box)" but I did NOT.
        Thank you for your help. Sorry about being so wrong.

        Comment

        • Jack Jackson

          #5
          Re: PictureBox created in code not working

          On Thu, 13 Nov 2008 20:09:10 -0800, AWW <wrote:
          >On Thu, 13 Nov 2008 12:56:30 -0800 (PST), kimiraikkonen
          ><kimiraikkonen 85@gmail.comwro te:
          >
          >>On Nov 13, 9:41 pm, AWW <wrote:
          >>XP VB 2005 running an example from help that creates a picturebox in
          >>code - the picturebox is not created.
          >> If I comment out the "Dim Box as New PictureBox" and create it in
          >>Design mode - the example works.
          >>I have tried Show, Enabled, Visible, and even BackColor.
          >>Why does a help example not work? and why does Design creation work?
          >>Thanks - I hope.
          >>
          >>It's not much clear what you mean, but as far as i understand, you
          >>don't see picturebox on your form, and i think that's because you
          >>didn't add picturebox control on your form by calling "Me.Controls.Ad d
          >>(Box)" and also you need to specify the location of your picturebox
          >>based on your example which you didn't tell its code.
          >>
          >>So, try this with assumption:
          >>
          >>Dim Box As New PictureBox
          >>Box.Image = Image.FromFile( "c:\picture.jpg ")
          >>Box.Locatio n = New Point(100, 100)
          >>' Equalize picturebox size with image size
          >>Box.Size = Box.Image.Size
          >>
          >>' Finally add control onto form
          >>Me.Controls.A dd(Box)
          >>
          >>Hope this helps,
          >>
          >>Onur Güzel
          >I said that I had "Me.Controls.Ad d(Box)" but I did NOT.
          >Thank you for your help. Sorry about being so wrong.
          That's why it helps if you post the code you are using.

          Comment

          • kimiraikkonen

            #6
            Re: PictureBox created in code not working

            On Nov 14, 6:09 am, AWW <wrote:
            On Thu, 13 Nov 2008 12:56:30 -0800 (PST), kimiraikkonen
            >
            >
            >
            <kimiraikkone.. .@gmail.comwrot e:
            On Nov 13, 9:41 pm, AWW <wrote:
            XP VB 2005 running an example from help that creates a picturebox in
            code - the picturebox is not created.
             If I comment out the "Dim Box as New PictureBox" and create it in
            Design mode - the example works.
            I have tried Show, Enabled, Visible, and even BackColor.
            Why does a help example not work? and why does Design creation work?
            Thanks - I hope.
            >
            It's not much clear what you mean, but as far as i understand, you
            don't see picturebox on your form, and i think that's because you
            didn't add picturebox control on your form by calling "Me.Controls.Ad d
            (Box)" and also you need to specify the location of your picturebox
            based on your example which you didn't tell its code.
            >
            So, try this with assumption:
            >
            Dim Box As New PictureBox
            Box.Image = Image.FromFile( "c:\picture.jpg ")
            Box.Location = New Point(100, 100)
            ' Equalize picturebox size with image size
            Box.Size = Box.Image.Size
            >
            ' Finally add control onto form
            Me.Controls.Add (Box)
            >
            Hope this helps,
            >
            Onur Güzel
            >
            I said that I had "Me.Controls.Ad d(Box)" but I did NOT.
            Thank you for your help. Sorry about being so wrong.
            So, your problem was solved by adding Me.Controls.Add (Box)?. I hope
            so.

            Thanks,

            Onur Güzel

            Comment

            Working...