Results 1 to 2 of 2

Thread: Repainting a Label and Picturebox???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Location
    Massachusetts
    Posts
    205

    Question Repainting a Label and Picturebox???

    I'm trying to use a progressbar one one form to change the text on another form's labels and change the image in the form's picturebox. Here's an example of what I have:

    Code:
    Dim h As String = wizardscreen9.Label1.Text
        Dim msg As String = wizardscreen9.Label2.Text
        Dim pic As Image = wizardscreen9.PictureBox1.BackgroundImage
        Dim easiertouse As String = My.Resources.easiertouse1
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            ProgressBar1.Increment(1)
            If ProgressBar1.Value = 10 Then
                h = "Easier to use"
                pic = My.Resources.easiertouse
                msg = easiertouse
            End If
    
    End Sub
    Yet the form won't repaint anything when I run the program. Any ideas how to fix this? I've already tried

    Code:
    wizardscreen9.invalidate
    and

    Code:
    application.doevents
    .

    Code:
    wizardscreen9.refresh
    NEVER works.

    So I have no idea what to do. Any ideas please??

  2. #2
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Re: Repainting a Label and Picturebox???

    I am a bit confused by seeing your code, as to exactly what you are trying to do.

    I suppose what you want is, when the progessbar value is 10, the values of h,msg,pic should be changed

    If so then use this

    vb Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         ProgressBar1.Increment(1)
    3.         If ProgressBar1.Value = 10 Then
    4.             wizardscreen9.Label1.Text = "Easier to use"
    5.             wizardscreen9.PictureBox1.BackgroundImage = My.Resources.easiertouse
    6.             wizardscreen9.Label2.Text = easiertouse
    7.         End If
    8. End Sub

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