473,409 Members | 1,952 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,409 software developers and data experts.

Drawing Shapes

Hi Im using VB express 2005

I encountered some problems while drawing shapes in visual basic. Whenever i print shape on the picturebox it appears, but when i minimize it or go to another form and then come back to the form where the picturebox is, the image will disappear and i have to click the button for the image to be visible again. Is there any way to make the image stay?



Expand|Select|Wrap|Line Numbers
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.  
  3.  
  4.         Dim gr As Drawing.Graphics = PictureBox1.CreateGraphics
  5.  
  6.         Dim br As Brush = Brushes.Blue
  7.  
  8.  
  9.  
  10.         Dim blackPen As New Pen(Color.SkyBlue, 3)
  11.         ' Create location and size of ellipse.
  12.         Dim x As Single = 4.0F
  13.         Dim y As Single = 7.0F
  14.         Dim width As Single = 25.0F
  15.         Dim height As Single = 30.0F
  16.         ' Draw ellipse to screen.
  17.         gr.DrawEllipse(blackPen, x, y, width, height)
  18.         gr.DrawEllipse(blackPen, 29, 7, 25, 30)
  19.         gr.FillEllipse(Brushes.Pink, x, y, width, height)
  20.         gr.FillEllipse(Brushes.Pink, 29, 7, 25, 30)
  21.         gr.DrawRectangle(Pens.SkyBlue, 53, 17, 20, 10)
  22.         gr.FillRectangle(Brushes.Pink, 53, 17, 20, 10)
  23.  
  24. End Sub
Regards
dr3amxstar
Aug 5 '07 #1
6 1901
lee123
556 512MB
maybe you have to put the code behind the form to
Aug 5 '07 #2
maybe you have to put the code behind the form to
Im sorry i dun get what u mean

If i put the code under form1_load, no image wil come out
Aug 6 '07 #3
Now my image is able to stay but it does not respond to my button click.Instead the image comes out when the form loads.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         PictureBox1.Invalidate()
  5.  
  6.     End Sub
  7.  
  8.     Private Sub PictureBox1_Paint(ByVal sender As Object, _
  9.     ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
  10.  
  11.  
  12.         Dim objPen As New Pen(Color.Blue)
  13.  
  14.  
  15.         e.Graphics.DrawRectangle(objPen, 10, 10, 200, 150)
  16.         e.Graphics.DrawLine(objPen, 10, 10, 210, 160)
  17.         e.Graphics.DrawLine(objPen, 210, 10, 10, 160)
  18.  
  19.  
  20.     End Sub
  21.  
  22. End Class
Aug 6 '07 #4
haha Solved already :D
Aug 8 '07 #5
Killer42
8,435 Expert 8TB
haha Solved already :D
Ah, you're too good for us!
Aug 8 '07 #6
Ah, you're too good for us!
nah... im not, haha just lucky.. you guys have been a great help to me :D
Aug 12 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew James | last post by:
Gentlemen, I'm looking for a graphing or drawing python package that will allow me to draw complex geometric shapes. I need to be able to create shapes like cogwheels and Venn diagrams: ...
0
by: Ron Adam | last post by:
I want to be able to easily create reusable shapes in Tkinter and be able to use them in mid level dialogs. So after some experimenting I've managed to get something to work. The following does...
3
by: steve bull | last post by:
I have a program in which I draw various shapes to a form but I would like to move it off the form into a user control. The painting on the form takes a significant amount of time. I was thinking of...
2
by: Heatland | last post by:
Hi I have not done anything like this using VB. I need to draw many round shapes on a rectangular. Can anyone point me do a right direction on where to start or give me some example code? ...
1
by: Andreas Schubert | last post by:
Hello newsgroup, I am pretty new to .NET and need some advise on how to approach to the following: I have to create an application with a drawing surface, where some predefined shapes...
2
by: Dursun | last post by:
Collegues, is it possible to do the foloowing: Let end user draw specific shapes (a circle that has a number within it and a connector that points to a specific area on the background image)...
10
by: Tina | last post by:
I need to find drawing software for my websites. I'm guessing that Adobe Photoshop is an overkill. What's best for creating bitmaps usable for websites? Thanks, T
7
by: ddecoste | last post by:
I have a need to add a visual representation to some data in Access. I need to draw a matix of squares inside another square. I have all the data that I need in a record in Access. The data...
2
by: mattc66 via AccessMonster.com | last post by:
Does anyone know of some simple line drawing add-on apps. I just need to be able to do some simple line drawing with dims. 4 walls and a door and allow the user to type the dims for the walls. All...
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?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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
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.