joker77 Posted December 20, 2006 Posted December 20, 2006 Hey, Just wondering is there any .NET equivalent to the Me.Circle method on a form for drawing a circle? Thanks Quote What if the Hokey-Pokey IS what it's all about?
MrPaul Posted December 20, 2006 Posted December 20, 2006 Graphics object Indeed there is an equivalent - .NET would appear a poor technology if something as simple as drawing a circle on a window wasn't possible ;). However, the method of doing so has changed a little from VB6. All drawing operations must be performed on a Graphics object. If you're drawing in the Paint event then a Graphics object is passed within the PaintEventArgs: 'Assumes the following Imports: Imports System.Windows.Forms Imports System.Drawing 'Paint event Private Sub MyForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles Me.Paint 'Draw a blue circle 40 pixels in diameter in the center of the form e.Graphics.DrawEllipse(Pens.Blue, _ CType((Me.ClientSize.Width / 2) - 20, Integer), _ CType((Me.ClientSize.Height / 2) - 20, Integer), _ 40, 40) End Sub If you wish to draw the circle at some other point in the code then you will have to create a Graphics object using the hWnd of the form or its BackgroundImage. Good luck :cool: Quote Never trouble another for what you can do for yourself.
joker77 Posted December 20, 2006 Author Posted December 20, 2006 Thanks for that - will get me started anyways - I haven't got the chance to do much with .NET so I might need to ask another couple of questions yet! Quote What if the Hokey-Pokey IS what it's all about?
Leaders snarfblam Posted December 20, 2006 Leaders Posted December 20, 2006 If you are drawing on a control, then you should know that each control also supplies a CreateGraphics method. [color="SeaGreen"]'Draw a circle that extends to the edges of SomeControl[/color] [color="Blue"]Dim[/color] g [color="Blue"]As[/color] Graphics = SomeControl.CreateGraphics() g.DrawEllipse( _ Pens.Black, SomeControl.Bounds) g.Dispose() [/Code] Note that you should always dispose of your Graphics objects. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.