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

Visual Studio 2005: VB fill circle automatic

How do I automatic move the X & Y to create a ellipse function as
below, DrawCircle?

Or there any sample source code out there?

I want it move down by user input. How can I achieve this? Thanks.

Imports System
Imports System.Drawing

Public Class circle

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

End Sub

Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid

Dim widthPen As Integer = 10
myPen.Width = widthPen

Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

myPen.Dispose()
End Sub

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

' Create pen.
Dim redBrush As New SolidBrush(Color.Red)

' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50

' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)

End Sub

End Class
Nov 27 '07 #1
4 2535
Now I got it work, now I want to remove the the ellipse at certain X &
Y.

I also have another program is that when I minimize it, my previous
ellipse is not visible. How can I fix this and remove the the ellipse
object at certain X & y? Thanks.

Here is the code:
Imports System
Imports System.Drawing
Public Class circle

Friend graphicGlobal As System.Drawing.Graphics
Dim x_global As Integer = 10
Dim y_global As Integer = 10
Dim width_global As Integer = 20
Dim height_global As Integer = 20

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

End Sub

Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid

Dim widthPen As Integer = 10
myPen.Width = widthPen

Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

myPen.Dispose()
End Sub

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

' Create brush
Dim redBrush As New SolidBrush(Color.Red)

' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50

' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)

Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)

DrawNote(40, 200, 50, 50, blueBrush)
DrawNote(60, 130, 50, 50, greenBrush)

End Sub

'good
'Private Sub DrawNote(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal colorBrush As
SolidBrush, ByVal e As System.Windows.Forms.PaintEventArgs)

'Dim redBrush As New SolidBrush(Color.Red)
'e.Graphics.FillEllipse(colorBrush, x, y, width, height)

'End Sub
Private Sub DrawNote(ByVal x As Integer, ByVal y As Integer, ByVal
width As Integer, ByVal height As Integer, ByVal colorBrush As
SolidBrush)

graphicGlobal = CreateGraphics()

graphicGlobal.FillEllipse(colorBrush, x, y, width, height)

End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Dim colorBrush As New SolidBrush(Color.Magenta)
Dim colorBrush2 As New SolidBrush(Color.Cyan)

DrawNote(x_global, y_global, 20, 20, colorBrush)

DrawNote(x_global + 15, y_global + 15, 20, 20, colorBrush2)

x_global = x_global + 30
y_global = y_global + 30

End Sub

End Class

On Nov 26, 6:27 pm, Slickuser <slick.us...@gmail.comwrote:
How do I automatic move the X & Y to create a ellipse function as
below, DrawCircle?

Or there any sample source code out there?

I want it move down by user input. How can I achieve this? Thanks.

Imports System
Imports System.Drawing

Public Class circle

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

End Sub

Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid

Dim widthPen As Integer = 10
myPen.Width = widthPen

Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

myPen.Dispose()
End Sub

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

' Create pen.
Dim redBrush As New SolidBrush(Color.Red)

' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50

' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)

End Sub

End Class
Nov 27 '07 #2


"Slickuser" wrote:
Now I got it work, now I want to remove the the ellipse at certain X &
Y.

I also have another program is that when I minimize it, my previous
ellipse is not visible. How can I fix this and remove the the ellipse
object at certain X & y? Thanks.

Here is the code:
Imports System
Imports System.Drawing
Public Class circle

Friend graphicGlobal As System.Drawing.Graphics
Dim x_global As Integer = 10
Dim y_global As Integer = 10
Dim width_global As Integer = 20
Dim height_global As Integer = 20

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

End Sub

Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid

Dim widthPen As Integer = 10
myPen.Width = widthPen

Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

myPen.Dispose()
End Sub

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

' Create brush
Dim redBrush As New SolidBrush(Color.Red)

' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50

' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)

Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)

DrawNote(40, 200, 50, 50, blueBrush)
DrawNote(60, 130, 50, 50, greenBrush)

End Sub

'good
'Private Sub DrawNote(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal colorBrush As
SolidBrush, ByVal e As System.Windows.Forms.PaintEventArgs)

'Dim redBrush As New SolidBrush(Color.Red)
'e.Graphics.FillEllipse(colorBrush, x, y, width, height)

'End Sub
Private Sub DrawNote(ByVal x As Integer, ByVal y As Integer, ByVal
width As Integer, ByVal height As Integer, ByVal colorBrush As
SolidBrush)

graphicGlobal = CreateGraphics()

graphicGlobal.FillEllipse(colorBrush, x, y, width, height)

End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Dim colorBrush As New SolidBrush(Color.Magenta)
Dim colorBrush2 As New SolidBrush(Color.Cyan)

DrawNote(x_global, y_global, 20, 20, colorBrush)

DrawNote(x_global + 15, y_global + 15, 20, 20, colorBrush2)

x_global = x_global + 30
y_global = y_global + 30

End Sub

End Class

On Nov 26, 6:27 pm, Slickuser <slick.us...@gmail.comwrote:
How do I automatic move the X & Y to create a ellipse function as
below, DrawCircle?

Or there any sample source code out there?

I want it move down by user input. How can I achieve this? Thanks.

Imports System
Imports System.Drawing

Public Class circle

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

End Sub

Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid

Dim widthPen As Integer = 10
myPen.Width = widthPen

Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)

myPen.Dispose()
End Sub

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

' Create pen.
Dim redBrush As New SolidBrush(Color.Red)

' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50

' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)

End Sub

End Class
If I understand what you are trying to do, you want to have control on the
drawing of an elipse as the control is repainted. You don't "erase" or
"remove" what is already there, but rather repaint the control. Think about
what you want drawn in your control and code your mainTab_Paint routine to
that.
>
Nov 27 '07 #3
Yes, is corrected. I want to control the ellipse that was previous
drawn.

If I re-draw with a different color (same as background) then it will
overlap and hide it.

But the problem is I don't know where that previous X & Y are (since
my X & Y will be random, my example here is increment every 10s by 30
though).

On Nov 27, 4:52 am, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"Slickuser" wrote:
Now I got it work, now I want to remove the the ellipse at certain X &
Y.
I also have another program is that when I minimize it, my previous
ellipse is not visible. How can I fix this and remove the the ellipse
object at certain X & y? Thanks.
Here is the code:
Imports System
Imports System.Drawing
Public Class circle
Friend graphicGlobal As System.Drawing.Graphics
Dim x_global As Integer = 10
Dim y_global As Integer = 10
Dim width_global As Integer = 20
Dim height_global As Integer = 20
Private Sub circle_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid
Dim widthPen As Integer = 10
myPen.Width = widthPen
Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)
x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)
myPen.Dispose()
End Sub
Private Sub DrawCircle(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
' Create brush
Dim redBrush As New SolidBrush(Color.Red)
' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50
' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)
Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)
DrawNote(40, 200, 50, 50, blueBrush)
DrawNote(60, 130, 50, 50, greenBrush)
End Sub
'good
'Private Sub DrawNote(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal colorBrush As
SolidBrush, ByVal e As System.Windows.Forms.PaintEventArgs)
'Dim redBrush As New SolidBrush(Color.Red)
'e.Graphics.FillEllipse(colorBrush, x, y, width, height)
'End Sub
Private Sub DrawNote(ByVal x As Integer, ByVal y As Integer, ByVal
width As Integer, ByVal height As Integer, ByVal colorBrush As
SolidBrush)
graphicGlobal = CreateGraphics()
graphicGlobal.FillEllipse(colorBrush, x, y, width, height)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim colorBrush As New SolidBrush(Color.Magenta)
Dim colorBrush2 As New SolidBrush(Color.Cyan)
DrawNote(x_global, y_global, 20, 20, colorBrush)
DrawNote(x_global + 15, y_global + 15, 20, 20, colorBrush2)
x_global = x_global + 30
y_global = y_global + 30
End Sub
End Class
On Nov 26, 6:27 pm, Slickuser <slick.us...@gmail.comwrote:
How do I automatic move the X & Y to create a ellipse function as
below, DrawCircle?
Or there any sample source code out there?
I want it move down by user input. How can I achieve this? Thanks.
Imports System
Imports System.Drawing
Public Class circle
Private Sub circle_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub mainTab_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim myPen As New
System.Drawing.Pen(System.Drawing.Color.Black)
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid
Dim widthPen As Integer = 10
myPen.Width = widthPen
Dim x1 As Integer = 10
Dim y1 As Integer = 20
Dim y2 As Integer = 70
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)
x1 = x1 + 25 + widthPen
e.Graphics.DrawLine(myPen, x1, y1, x1, y2)
myPen.Dispose()
End Sub
Private Sub DrawCircle(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
' Create pen.
Dim redBrush As New SolidBrush(Color.Red)
' Create location and size of ellipse.
Dim x As Integer = 75
Dim y As Integer = 25
Dim width As Integer = 75
Dim height As Integer = 50
' Draw ellipse to screen.
e.Graphics.FillEllipse(redBrush, x, y, width, height)
End Sub
End Class

If I understand what you are trying to do, you want to have control on the
drawing of an elipse as the control is repainted. You don't "erase" or
"remove" what is already there, but rather repaint the control. Think about
what you want drawn in your control and code your mainTab_Paint routine to
that.

- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Nov 27 '07 #4
Yes, is corrected. I want to control the ellipse that was previous
drawn.
If I re-draw with a different color (same as background) then it will
overlap and hide it.

But the problem is I don't know where that previous X & Y are (since
my X & Y will be random, my example here is increment every 10s by 30
though).
On Nov 27, 4:52 am, Family Tree Mike

You can do a graphics clear at the top of your mainTab_Paint(), but there
may be some flickering if the updates are very frequent.
>
Nov 27 '07 #5

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

Similar topics

11
by: olle | last post by:
Hi everyone. I am an Access developer having worked with Access-dev. projects for many years on Sql server databases and Access. For the internet I have been using traditional asp. But now I have...
3
by: Shapper | last post by:
Hello, I am starting 2 new projects to deliver in January 2006. I want to create them in Asp.Net 2.0 using Visual Studio 2005. All my clients web sites are Visual Studio 2003 projects in...
0
by: fiona | last post by:
Innovasys Ltd., a leader in help authoring and documentation tools, today announced the inclusion of a tailored version of the Innovasys HelpStudio help authoring product, HelpStudio Lite, in the...
8
by: WT | last post by:
Is it normal that Visual Studio sets the PreInit handler for a Page from the OnInit code ? No chance to fire it as OnPreInit is run befor OnInit. ??? CS
3
by: Edwin Smith | last post by:
I have a 2 form project in VS2005 that now hangs whenever I try to do anything with the second form. This seems to have started when I added some SQL tables from a Pervasive v.9 database using the...
0
by: nemo | last post by:
Hello, I m looking for a feature that could really help everyone debugging code. I often have to use the "Attach to Process..." function from Visual Studio 2005 Prof. to debugg my code called...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
4
by: RSH | last post by:
I have a project that we have had in 2005 for a couple months now and everything has been working fine. Now today I open it up and get the latest version from SourceSafe and I made a few changes...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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,...
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...

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.