How to reproduce this error?

Create a new winform

Select a backgound image for the form

Add a new panel

Set color transparent for the panel, set autoscroll = true, and add some controls inside the panel

Example:

http://i.stack.imgur.com/YxRhx.jpg

Now scroll down or up and see the what I say...

http://i.stack.imgur.com/cUsOW.jpg

How to correct this error?

Me: I've Tried all, No idea

Invalidate and Refresh method don't work for this, it "flashes" the panel all the time when scroll down/up, it only disimulate the problem...

'Mouse wheel scrollbar
Public Sub panel1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseWheel
Panel1.Invalidate()
End Sub

Someone told me to create a vScrollbar and handle it in my panel to adjust the minimum scrolled lines at time, for example to scroll 15 lines intead of default 6 lines, because if I scroll one entire page I don't get any visual problem, but i don't know how to do all that...

.Net does not support true transparency. Transparency is mimicked by copying the foreground of the parent control to the background of the "transparent" control. That stated, the best that you can do is to try and mitigate the problems. You are on the right track by invalidating the panel to force a redraw of the background. There are a few things that can help the flickering, but it will still be there. The slower your computer's graphics, the worse the flickering will be.

Here is a custom Panel control that I've found to give acceptable results.

Public Class TransPanel
   Inherits Panel
   Public Sub New()
      BackColor = Color.Transparent
      AutoScroll = True
      ' setting these 2 styles has a big positive effect
      SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
      SetStyle(ControlStyles.AllPaintingInWmPaint, True)
   End Sub

   Protected Overrides Sub OnScroll(ByVal se As System.Windows.Forms.ScrollEventArgs)
      MyBase.OnScroll(se)
      Refresh()
   End Sub

   Protected Overrides Sub OnMouseWheel(ByVal e As System.Windows.Forms.MouseEventArgs)
      MyBase.OnMouseWheel(e)
      Refresh()
   End Sub

End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.