473,233 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

Draw over controls

I have a panel that contains a label and a picturebox. When clicked, I
want to draw a rectangle over everything. I can draw the rect and set
the color, no big deal. The problem is because I have to pass the rect
of the panel, it draws on that, and under the other controls. How can
I force it to draw OVER everything else? Ideally this would also be
trackable since the whole thing(panel and children) will be dragable.
This is what i've got right now:

Graphics gfx = selectedCtrl.CreateGraphics();
gfx.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Crimson)),
selectedCtrl.ClientRectangle);

Where selectedCtrl is the control that was clicked.

Thanks,
Brandon

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
Aug 4 '08 #1
3 5051
On Aug 4, 6:54*pm, Brandon Arnold <reason...@gmail.comwrote:
I have a panel that contains a label and a picturebox. When clicked, I
want to draw a rectangle over everything. I can draw the rect and set
the color, no big deal. The problem is because I have to pass the rect
of the panel, it draws on that, and under the other controls. How can
I force it to draw OVER everything else? Ideally this would also be
trackable since the whole thing(panel and children) will be dragable.
You shouldn't really draw outside Paint events, because other controls
can decide to redraw at arbitrary moment of time, and will erase your
changes. Instead, just create an empty Panel of the desired color, and
place it where you want your rectangle to be displayed. If you want
some fancy filling on the panel (gradient, etc), then, instead of
changing its BackColor, handle its Paint event and paint whatever you
want in it.
Aug 4 '08 #2
On Mon, 4 Aug 2008 09:07:36 -0700 (PDT), Pavel Minaev
<in****@gmail.comwrote:
>On Aug 4, 6:54*pm, Brandon Arnold <reason...@gmail.comwrote:
>I have a panel that contains a label and a picturebox. When clicked, I
want to draw a rectangle over everything. I can draw the rect and set
the color, no big deal. The problem is because I have to pass the rect
of the panel, it draws on that, and under the other controls. How can
I force it to draw OVER everything else? Ideally this would also be
trackable since the whole thing(panel and children) will be dragable.

You shouldn't really draw outside Paint events, because other controls
can decide to redraw at arbitrary moment of time, and will erase your
changes. Instead, just create an empty Panel of the desired color, and
place it where you want your rectangle to be displayed. If you want
some fancy filling on the panel (gradient, etc), then, instead of
changing its BackColor, handle its Paint event and paint whatever you
want in it.
Right now, I have all my controls and their associated labels together
in seprate panels. Adding more panels seems rather, ugly. Would it
be considered bad form to use them so liberaly? Right now i'm toying
around with that idea. I've placed a panel over the controls(and
parent panel) and when the desired control set is clicked, the overlay
panel is displayed. It works right now with solid colors being set
but i'm having an issue with transparency, but I can work that out.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
Aug 4 '08 #3
On Aug 4, 8:26*pm, Brandon Arnold <reason...@gmail.comwrote:
Right now, I have all my controls and their associated labels together
in seprate panels. *Adding more panels seems rather, ugly. *Would it
be considered bad form to use them so liberaly?
Not really. Note also, that in .NET 3.5, there is a bunch of controls
that are specifically useful to "draw" shapes on the form -
RectangleShape, OvalShape, LineShape etc (they come from VB Power Pack
originally). If you have 3.5, you might want to use those instead of
Panel, as they are somewhat more lightweight.
Aug 5 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raja | last post by:
Dear Members, Has anyone used the Vector Draw (www.vdraw.com) Component in Visual Basic. I need to create an application to be able to draw the plan view of a building. Any help in this regard...
1
by: Crirus | last post by:
I know subject is confusing... This is the ideea: I have 3 controls..custom. I have a control that act as a container for them.. does 3 containers fill completly the container one... That...
3
by: Colin McGuire | last post by:
Hi there. I have written a small procedure to draw various shapes on things. A bit of it is shown below. Private Sub drawShape(ByVal shapeType As Integer, ByRef g As Graphics) Select Case...
2
by: John | last post by:
I created a number of pictureboxes in a panel, and want to draw lines in those pictureboxes but I cannot. Please see the following code and make corrections. Thanks. Private Sub...
1
by: Jeff Waskiewicz | last post by:
Hello All, I'm trying to solve a nagging problem. The goal is to draw a rectangle over the top of all the other controls on a form. Specifically, over a ChartFX control. The user would draw...
8
by: George | last post by:
Hello everyone, I am using C# on a Pocket PC 2003 project based on .Net Compact Framework of Visual Studio 2005. I want to re-draw some controls of a Form (Window) at a regular interval (for...
9
by: zhaow | last post by:
Hi, All Greetings! I want to develop as appllication that requires a line-drawing function in the blank area between two forms. I have looked up the MSDN, it says that a graphics object need a...
2
by: Sagaert Johan | last post by:
Hi I want to draw grips around my usercontrol. Becorse the grips are around the customcontrol they are outside the controls drawing area. I tried setting the Region to infinit but that does not...
10
by: Phil | last post by:
I would like to draw some text which will be in front of any other controls, but without obscuring them completely. If I use DrawString in the form's Paint handler the text is always behind, not in...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.