I've developed a program that inserts an array of Panel-like controls into another Panel control, the code is as follows:
Dim ModSe As Bitmap = Nothing
ModSe = My.Resources.example
Dim pbdoors As New Panel With {
.Width = 100,
.Height = 200,
.Top = 10,
.Left = 10,
.BorderStyle = BorderStyle.FixedSingle,
.BackgroundImage = ModSe,
.BackgroundImageLayout = ImageLayout.Stretch,
.ContextMenuStrip = CntxtMnuStrpUnit,
.Name = ("Test")
}
But when I see the arrangement of Panel controls already inserted, when I step over a control type Tab, they start to flash as if it were a strobe light. In this case, for my Form, I went to the "DoubleBuffered" property and set it to True, but it keeps flashing.
Add the following without any results.
Public Class FlickerPanel
Inherits System.Windows.Forms.Panel
Public Sub New()
MyBase.New()
Me.SetStyle(ControlStyles.Opaque, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.EnableNotifyMessage, True)
End Sub
Protected Overrides Sub OnNotifyMessage(ByVal m As Message)
If (m.Msg <> &H14) Then
MyBase.OnNotifyMessage(m)
End If
End Sub
End Class
Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
'Dim cp As CreateParams = MyBase.CreateParams
'cp.ExStyle = cp.ExStyle Or 33554432
'Return cp
Dim cp As CreateParams = MyBase.CreateParams
Dim OSVer As Version = System.Environment.OSVersion.Version()
Select Case OSVer.Major
Case Is <= 5
Case 5
If OSVer.Minor > 0 Then
cp.ExStyle = cp.ExStyle Or &H2000000
End If
Case Is > 5
cp.ExStyle = cp.ExStyle Or &H2000000
Case Else
End Select
Return cp
End Get
End Property
Please, how can I eliminate this flicker?