473,854 Members | 1,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help for DRAWRECTANGLE

Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing. Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphi cs

GR.DrawRectangl e(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 1724
"Cristian" <cr*********@li bero.it> schrieb
Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing. Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphi cs

GR.DrawRectangl e(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(ByV al sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Me.Paint

Dim g As Graphics = e.Graphics

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

End Sub

Ken

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

"Cristian" <cr*********@li bero.it> wrote in message
news:t6******** ************@tw ister1.libero.i t...
Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing. Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphi cs

GR.DrawRectangl e(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*********@li bero.it> schrieb:
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphi cs

GR.DrawRectangl e(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.Draw Rectangle(...)
///

--
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*********@li bero.it> ha scritto nel messaggio
news:t6******** ************@tw ister1.libero.i t...
Hi.
I've made so:

Imports System.Drawing
Imports System.Drawing. Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim GR As Graphics = Me.CreateGraphi cs

GR.DrawRectangl e(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*********@li bero.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
1653
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 onpaint event and added the code to draw my rectangle and position my graphic items: Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) e.Graphics.Clear(Color.FromArgb(255, 255, 255))
7
1463
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 = PenAlignment.Inset; e.Graphics.DrawRectangle(pen,Rect);
1
2577
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 to identify it as selected. The DrawRectangle works fine when the child controls is on left half of the custom control area but fails to draw the rectangle when moved to right half of the custom control. When placed some where in between we see...
2
1349
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 nothing with an ico if you want to show an icon in the menu) also add a module and copy paste the code at the bottom of the message. Private Sub MenuItem1_DrawItem1(ByVal sender As Object, ByVal e As _
2
3389
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 original background of the window(s) behind the rectangle)? Thanks... Dan
1
3790
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 ....
2
3514
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 there ways to change the default behavior? The reason I ask is cause when I do g.DrawRectangle(P, this.ClientRectangle) for drawing a rectangle as the border for a control(button) and the width of P is larger than 1(or even when its not it...
10
4654
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: Accept the width of the largest square Output: A series of nested squares with 1 space between them Sample: > eca4.exe 10 ********** * * * ****** *
1
3537
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
9901
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11025
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10682
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
10758
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
10371
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7915
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
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();...
1
4562
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
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.