473,773 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cr eateGraphics();
gfx.FillRectang le(new SolidBrush(Colo r.FromArgb(100, Color.Crimson)) ,
selectedCtrl.Cl ientRectangle);

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 5085
On Aug 4, 6:54*pm, Brandon Arnold <reason...@gmai l.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.c omwrote:
>On Aug 4, 6:54*pm, Brandon Arnold <reason...@gmai l.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...@gmai l.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
3833
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 would be highly appreciated. Best Regards RSB
1
1122
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 container control is the one I use in my form Anyway, I draw some fancy borders on the parent control (the container). Question: Is there any chance to draw on a upper layer that is visible over does controls?
3
10329
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 shapeType Case 1 : g.DrawRectangle(New Pen(Color.Black), 0, 0, 50, 10) Case 2 'draw a circle Case 3 'draw a triangle Case 4 'draw other shape Case 5 'draw other shape
2
3060
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 Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Panel1.AutoScroll = True Panel1.Width = 200 Panel1.Height = 200
1
3777
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 the rectangle using the right mouse button to represent the area of the chart they want to zoom on. I haev been able to draw the rectangle on a blank form but I cannot get it to draw on top of other controls. I have pasted in the code i am using ....
8
2775
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 example, change the title of some Label or something similar). The issues I met with are, 1. My application has several Forms/Windows. How to check whether the specific Form/Window (which I want to re-draw) is active? If the Form/Window
9
4028
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 reference to a control or a form. I guess it means that lines can't be draw on blank area between two forms. Can anybody guarantee this for me? Is there any method can realize this function? I mainly want to draw a line from a button in form1 to...
2
2511
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 seem to work. Any hints or workarounds ? Johan
10
7532
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 front of the other controls. In VB6 I would have simply used a label control and set it to transparent, but this doesn't work in .NET, the background of a label can be set to 'transparent', but this does not show the other controls through,...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6717
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.