473,654 Members | 3,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing Shapes

55 New Member
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 1911
lee123
556 Contributor
maybe you have to put the code behind the form to
Aug 5 '07 #2
dr3amxstar
55 New Member
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
dr3amxstar
55 New Member
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
dr3amxstar
55 New Member
haha Solved already :D
Aug 8 '07 #5
Killer42
8,435 Recognized Expert Expert
haha Solved already :D
Ah, you're too good for us!
Aug 8 '07 #6
dr3amxstar
55 New Member
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
1505
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: http://encyclopedia.thefreedictionary.com/Venn The library must support alpha blending and the ability to return x,y co-ordinates for a shape, as I want to draw an imagemap on top of parts of the shape.
0
2791
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 pretty much what I need, but I think it can be improved on. So could anyone take a look and let me know what you think? Some of the things I want to add, but aren't exactly sure how at this time: Nested groups Use tags to be able to change sub...
3
3062
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 making a bitmap map to the control so that when it does a refresh it doesn't need to recalculate everything. It is easy using the form because I have clipping and all the graphics draw routines(line, polygon etc). Is there a way to draw to a...
2
1146
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? Thanks very much in advance.
1
2515
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 (picture boxes with icons in it) can be dropped and moved around. This should work like some MS Visio on a very basic level. The shapes should be dragged from a list.
2
2615
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) using Windows Forms and controls. To be more specific, I want to design a VB.Net Windows form where end user will mark damages on an airplane picture (which might be background picture of the form) using a marker object that has a circle (with a...
10
2178
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
7056
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 changes according to what the user inputs. I know that Access does not allow you to draw on forms so I decided to put the output in an Excel file for the user but I am having trouble drawing the rectange from Access. Here is my simple code so far: ...
2
3222
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 simple. Thanks MAtt -- Matt Campbell mattc (at) saunatec com
0
8372
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
8285
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
8706
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
8475
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
8591
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
6160
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
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2709
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
1
1915
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.