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()
-
MyBase.New()
-
End Sub
-
-
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
-
MyBase.OnPaint(e)
-
-
'Set the backcolor of the panel according to the focus on it.
-
If Me.ContainsFocus Then
-
Me.BackColor = Color.Yellow
-
Else
-
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
-
1 2336
The following line needs to be changed. - ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, BorderColor, borderWidth, ButtonBorderStyle.Solid, BorderColor, borderWidth, ButtonBorderStyle.Solid, BorderColor, _
-
borderWidth, ButtonBorderStyle.Solid, BorderColor, borderWidth, ButtonBorderStyle.Solid)
The reason I draw border for e.ClipRectangle, which may be just a small part of the control that has been invalidated for current paint event. So I need to use the control's ClientRectangle property.
For more advanced painting the clip rectangle can be used to only redraw the invalidated area.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dales |
last post by:
I have a custom control that builds what we refer to as "Formlets"
around some content in a page. These are basically content "wrapper"
sections that are tables that have a colored header and...
|
by: Dexter |
last post by:
Hello all,
I'm building a web custom control, but i hava a problem.
In the Sub Render, i have a html code as output. All ok.
I have a other class that has a function that return a image object,...
|
by: Dexter |
last post by:
Hello all,
I'm developing a custom web control that mount a webpage,
but now i don't can to modify the properties of my custom web control.
by exemplo:
the property NumeroGuia is 0 by default,...
|
by: Martin |
last post by:
Hi,
I have produced a custom server control that simple outputs a row of 26
buttons, one button for each letter of the english alphabet.
now what I would like to do is catch the button click...
|
by: Shimon Sim |
last post by:
I have a custom composite control
I have following property
|
by: BoloBaby |
last post by:
OK, check this out...
I have a form with a panel control and button on it (outside the panel
control).
I have two event handlers - one handles the click event of the button on the
form. The...
|
by: shumaker |
last post by:
How do I make a panel control invisible, but still recieve events?
I have a panel that I set visible= false, and over it I am using GDI+
to paint a grid of rectangles. It has to be invisble or...
|
by: Smokey Grindle |
last post by:
I am trying to write a custom panel control that I can place objects into at
design time, however, i want a header on the top of it which can not contain
controls (its a static header) in the image...
|
by: Charles Zhang |
last post by:
I want to create a simple server control that does thing like:
<Mc:CollapsibleControl TitlePanelID="panel1" BodyPanelID="Panel2">
<asp:Panel ID="panel1">
...
</asp:Panel>
<asp:Panel...
|
by: melance |
last post by:
I am developing a custom panel control that inherits the usercontrol and uses a designer that inherits the parentcontroldesigner. It has a panel on the control where controls will be placed and a...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |