DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Mar 2009

    Question Problem in painting custom panel control (.Net Framework 4.0).

    I have inherited the standard panel control to create a panel having custom border color. The problem is, while the panel is on a form and any other form is moved across it, it paints hapazard lines of the same color as the panel custom border color, all throughout background of the panel. I tried to Refresh or Invalidate the panel in its paint event but of no avail. The same is happening while designing in the design editor too. See attached image. Why is this happening and how to get rid of it?
    My code follows:

    Namespace CustomPanelControl
        Public Class CustomPanel
            Inherits Panel
            Public Sub New()
            End Sub
            Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
                'Set the backcolor of the panel according to the focus on it.
                If Me.ContainsFocus Then
                    Me.BackColor = Color.Yellow
                    Me.BackColor = Color.White
                End If
                'Draw the border of the panel.
                If Me.BorderStyle = BorderStyle.None Then
                    Dim borderWidth As Integer = 1
                    Dim BorderColor As Color = Color.Blue
                    ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, BorderColor, borderWidth, ButtonBorderStyle.Solid, BorderColor, borderWidth, ButtonBorderStyle.Solid, BorderColor, _
                    borderWidth, ButtonBorderStyle.Solid, BorderColor, borderWidth, ButtonBorderStyle.Solid)
                End If
            End Sub
        End Class
    End Namespace
    Attached Images Attached Images

Similar Threads

  1. Replies: 6
    Last Post: 04-08-2011, 10:20 PM
  2. .net Web Custom Control Deployment
    By derekbeacroft in forum ASP.NET
    Replies: 0
    Last Post: 03-08-2011, 12:47 PM
  3. Replies: 0
    Last Post: 02-02-2011, 09:28 AM
  4. Creating control panel applets in .NET
    By Boris F. in forum .NET
    Replies: 3
    Last Post: 07-27-2001, 03:28 PM
  5. WEIRD ActiveX control problem
    By Glenn in forum ASP.NET
    Replies: 0
    Last Post: 12-13-2000, 07:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.