473,406 Members | 2,745 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,406 software developers and data experts.

Help for DRAWRECTANGLE

Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphics

GR.DrawRectangle(Pens.Red, 100, 30, 150, 190)

End Sub

End Class

But when the program was executed I saw only the form!!
Please Help Me
Bye
Cris
Dec 13 '05 #1
5 1706
"Cristian" <cr*********@libero.it> schrieb
Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphics

GR.DrawRectangle(Pens.Red, 100, 30, 150, 190)

End Sub

End Class

But when the program was executed I saw only the form!!

In Form_Load, the form is not visible yet. Painting on an invisible Form
does not makes sense. On the other side, you don't paint if it is visible.
To do this, handle the Paint event.

Background and basics:
http://msdn.microsoft.com/library/en...tdraw_8alz.asp

http://msdn.microsoft.com/library/en...tdraw_4k6d.asp

http://msdn.microsoft.com/library/en...tdraw_1xd1.asp

(The Paint event is raised whenever the Form receives a WM_PAINT Message).
Armin

Dec 13 '05 #2
Hi,

Never draw in the forms load event it will be erased when the form
paints itself. Use the paint event instead.

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim g As Graphics = e.Graphics

g.DrawRectangle(Pens.Red, 100, 30, 150, 190)

End Sub

Ken

--------------------

"Cristian" <cr*********@libero.it> wrote in message
news:t6********************@twister1.libero.it...
Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphics

GR.DrawRectangle(Pens.Red, 100, 30, 150, 190)

End Sub

End Class

But when the program was executed I saw only the form!!
Please Help Me
Bye
Cris

Dec 13 '05 #3
"Cristian" <cr*********@libero.it> schrieb:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphics

GR.DrawRectangle(Pens.Red, 100, 30, 150, 190)

End Sub

End Class

But when the program was executed I saw only the form!!


Add the code to your form's 'Paint' event handler:

\\\
e.Graphics.DrawRectangle(...)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 13 '05 #4
NO!
OK! I've result.
It's WRONG that is not possible write on invisible form!!!
In ON_LOAD the form is already existent!!
Soo Thank.
Bye

"Cristian" <cr*********@libero.it> ha scritto nel messaggio
news:t6********************@twister1.libero.it...
Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphics

GR.DrawRectangle(Pens.Red, 100, 30, 150, 190)

End Sub

End Class

But when the program was executed I saw only the form!!
Please Help Me
Bye
Cris

Dec 13 '05 #5
"Cristian" <cr*********@libero.it> schrieb
NO!
OK! I've result.
It's WRONG that is not possible write on invisible form!!!
No, it's TRUE that it is not possible.
In
ON_LOAD the form is already existent!!


Yes, but it is not visible.
Armin
Dec 13 '05 #6

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

Similar topics

2
by: padawan | last post by:
I have a winforms control that draws a rectangle for a boarder and positions some graphical elements around the control to create the boarder effect I desired. In the control I have overriden the...
7
by: KVV | last post by:
Hello, All! SolidBrush brush = new SolidBrush(SystemColors.Control); e.Graphics.FillRectangle(brush,Rect); Why this code draw and this Pen pen = new Pen(brush,drawWidth); pen.Alignment =...
1
by: Siri Krishna | last post by:
Hi, We have a custom control into which we add controls like labels and move them at run time. The problem we have is that when a child control is selected and moved, we draw a rectangle around it...
2
by: Peter Proost | last post by:
Hi, I've got the following ownerdraw menu: drag a mainmenu on a form and add some menuitems to it, set all the menuitems to ownerdraw = true and for every menuitem add this code (replace...
2
by: Dan | last post by:
I want to use Graphics.DrawRectangle to draw a rectangle at a position on the screen, and then a few seconds later, erase it. How do you erase a rectangle that you just drew (without affecting the...
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...
2
by: Jon Slaughter | last post by:
How does DrawRectangle position a rectangle w.r.t to the Rectangle passed? Lets suppose I use a pen of width 5. Are the lines centered about the passed Rectangle or is it enclosed or offset? Are...
10
by: wazzup | last post by:
C++ is new to me and I'm trying solve this problem but get stuck. Please help me out. Below is the task and after that is what i got so far. Create a program to print nested squares Input:...
1
by: t f | last post by:
Hi FillRectangle allows me to use a rectanglef as a parameter, why doesnt DrawRectangle? Even though I can use floats as parameters? Did M$ forget to add it? Thanks t f
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
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...
0
tracyyun
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...
0
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,...
0
isladogs
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 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.