Results 1 to 3 of 3

Thread: Picturebox property question - crucial

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    I'm having difficulty with a very important part of my project. If there's no way around it I'd like to give whoever wrote VB6 a piece of my mind. There's no reason why it should happen.

    It's to do with the Autoredraw property of the picturebox.

    I have some command buttons and a picturebox on my form. Some command buttons bring up another form which, when they cover the picturebox, erase it's contents. So I set the 'Autoredraw' property to True. Problem solved for a while.

    But the contents of the Picturebox can change at run time.

    For example:

    'print a random number between 0 and 10 in the picturebox
    'every time command button is clicked, a number is printed
    'at the specified coordinates
    Private Sub Command1_Click()
    'refresh to erase the previous number
    Picture1.Refresh
    Picture1.CurrentX = 10
    Picture1.CurrentY = 10
    Picture1.Print Int(Rnd * 10)
    End Sub


    I'm in a dilemma: If Autoredraw of the Picturebox is set to 'True', the contents of the Picturbox don't erase at all - one random number prints over the next, when the button is pressed. I thought the Refresh command would get rid of this, but it doesn't.

    And if I set Autoredraw to 'False', the previous random number disappears (as it should) but everything disappears when a form is placed over it.

    Is this some sort of sick joke? Is there a way to get rid of the previous random number - rather than print directly on top of it, and yet keep contents in the picture box when a form is moved on top of it?

    Thanks!

  2. #2
    Guest
    Use the Cls method.

    Code:
    Picture1.Cls

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Thumbs up


    Megatron, thanks a lot. Never heard of that method.

    It looks like I can replace all my Picture1.Refresh stuff, too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width