Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Setting background image.

Avatar of Kinger247
Kinger247 asked on
.NET ProgrammingVisual Basic.NET
2 Comments1 Solution323 ViewsLast Modified:
Hi all,

Via the onPaint event I’m trying to draw some boxes/text on a control over the selected background image.
But I need to clear the control before each paint event to stop blurring of text, but this stops me showing the background image.

How can I get around this or should I say “do it correctly” ?

I want to be able to use the controls BackgroundImage / BackgroundImageLayout properties.

My code below ...

Thanks in advance
K.


  Public Overrides Property BackgroundImage() As Image
    Get
      Return _BackgroundImage
    End Get
    Set(ByVal value As Image)
      _BackgroundImage = value
      MyBase.BackgroundImage = value
      Me.Invalidate()
    End Set
  End Property

  Private _BackgroundImage As Image = Nothing

  Private Sub ucGraph_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

    BackBuffer = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
    Using gr As Graphics = Graphics.FromImage(BackBuffer)
      gr.SmoothingMode = SmoothingMode.HighQuality
      gr.InterpolationMode = InterpolationMode.High
      gr.Clear(Color.White)

      MyBase.BackgroundImage = _BackgroundImage

      'Draw everything else here .......

    End Using

    e.Graphics.DrawImageUnscaled(BackBuffer, 0, 0)
  End Sub
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike TomlinsonFlag of United States of America imageHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers