Poppa Mintin
Well-known member
- Joined
- Jan 4, 2018
- Messages
- 45
- Programming Experience
- 10+
Hi,
I'm trying to draw 36 dots on my windows form 1. For the purpose of this question I've increased the size of the dots to be much larger circular ellipses.
Here is Form1. Clicking 'Dots' ought to draw 36 'dots' on the form in 6 rows of 6 columns, to form the corners of 25 boxes in a 5 x 5 grid.
Here is the code:
Clicking 'Dots' actually produces: -
All the maths works out correctly when viewed stepped through from a breakpoint. I have used several different options of numbers of 'Boxes', 5x5, 5x10, 10x10, 15x10. All exhibit this strange result, just a small area drawn to.
I can't find anything which might cause this in the properties dialogue, which confirms that there are only 2 Buttons and a Label on the form. The borders are set to 'None' but trying other options makes no difference.
I'm at a loss to understand what's going on.
Poppa.
VS 2017 Community Version 15.5.5.
Windows 10. from initial install.
Intel i7 machine.
I'm trying to draw 36 dots on my windows form 1. For the purpose of this question I've increased the size of the dots to be much larger circular ellipses.
Here is Form1. Clicking 'Dots' ought to draw 36 'dots' on the form in 6 rows of 6 columns, to form the corners of 25 boxes in a 5 x 5 grid.
Here is the code:
VB.NET:
Public Class Form1
Dim box, col, row, sptX, sptY As Int32
Dim pen1 As Pen = New Pen(Color.Black, 1)
Dim sldBsh As New SolidBrush(Color.Black)
Dim gObjet As Drawing.Graphics = Me.CreateGraphics()
Private Sub Form1_Load() Handles MyBase.Load
Button1.Text = "EXIT"
Button2.Text = "Dots"
Initialise()
End Sub
Private Sub B1_Click() Handles Button1.Click
Application.Exit()
End Sub
Private Sub B2_Click() Handles Button2.Click
Dots()
End Sub
Public Sub Initialise()
Dim meX, meY As Int32, Scn As Screen = Screen.AllScreens(0)
' AllScreens(0): 0 = THIS screen, others are 1, 2 etc.
' Setup Form1 size and position.
col = 5
row = 5
box = CInt(Scn.Bounds.Width / (col + 10)) ' Square box size.
Me.Width = box * (col + 1)
Me.Height = CInt(box * (row + 1)) + Button1.Height
meX = CInt((Scn.Bounds.Width - Me.Width) * 0.5)
meY = CInt((Scn.Bounds.Height - Me.Height) * 0.5)
Me.Location = New Point(meX, meY)
' Setup variables.
Label1.Text = CInt(col * row).ToString & " boxes"
Me.Show()
End Sub
Private Sub Dots()
' Draw spots.
sptY = CInt(box / 2)
For i = 0 To col
sptX = CInt(box / 2) 'col
For j = 0 To row
Dim rect As Rectangle = New Rectangle(sptX, sptY, 60, 60)
gObjet.FillEllipse(sldBsh, rect)
sptX += box
Next
sptY += box 'row
Next
End Sub
End Class
All the maths works out correctly when viewed stepped through from a breakpoint. I have used several different options of numbers of 'Boxes', 5x5, 5x10, 10x10, 15x10. All exhibit this strange result, just a small area drawn to.
I can't find anything which might cause this in the properties dialogue, which confirms that there are only 2 Buttons and a Label on the form. The borders are set to 'None' but trying other options makes no difference.
I'm at a loss to understand what's going on.
Poppa.
VS 2017 Community Version 15.5.5.
Windows 10. from initial install.
Intel i7 machine.