In my code I am trying to draw/define a line but despite my best efforts
I cannot make it appear as thick as I would like.
To be more exact I cannot do that INSIDE A GROUP BOX,
although outside that box the definition is exactly as required.
The full code is at the bottom here but please let me confine discussion
as narrowly as I need to.
First, when you run the code you may see that this is some kind of Sudoku puzzle,
or at least the start of one. But please let me stick to what the program is or is not actually doing.
Now look at the 'Bolds' on the right of the form. Click one at random ( 6, say. )
Now click on any of the squares on the (group) box on the left.
Two things of interest here should happen :
the '6' appears in the box clicked ( which is, for me, the good news ).
Second, the borders of that box will shrink and/or disappear
( depending on which particular box was clicked ).
For me that is the bad news and why this thread exists.
Now I have tried to start 'manually' redrawing the box in question.
Two new lines have also appeared since you clicked the '6' into a cell.
One of these lines is outside the box ( where I have been thinking ),
below the 'X,Y,Z' buttons.
The other line is in the groupbox, at the left border of cell (6,4 ).
These lines were defined/drawn in Sub drawSquare.
Note first that they were Dimmed as Labels
( because VB.Net does not allow the definition of LineSpaces in code).
In each case the 'X' dimension of these lines is set at 3,
effectively making the Label a Linespace.
The problem is though that inside the groupbox the drawn line is TOO THIN,
with an apparent thickness of 1.
What is the easiest way to correct this, please ?
Here is my code :
Public Class frmPuzl
Dim bXY(9, 9) As Label
Dim cXY(9, 9) As Label
Private Sub formAll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load
For i = 1 To 9
For j = 1 To 9
cXY(i, j) = New Label
cXY(i, j).Location = New Point((50 * (i - 1)), (14 + 50 * (j - 1)))
cXY(i, j).Size = New System.Drawing.Size(49, 49)
cXY(i, j).Tag = CStr(j + 10 * i)
cXY(i, j).Text = " "
'cXY(i, j).Text = cXY(i, j).Tag
cXY(i, j).BackColor = numTemplate.BackColor
cXY(i, j).BackColor = Color.White
cXY(i, j).Font = numTemplate.Font
cXY(i, j).BorderStyle = numTemplate.BorderStyle
cXY(i, j).TextAlign = numTemplate.TextAlign
cXY(i, j).Visible = True
gbXY.Controls.Add(cXY(i, j))
' AddHandler cXY(i, j).Click, AddressOf Response
AddHandler cXY(i, j).MouseUp, AddressOf Response
Next
Next
End Sub
Private Sub Response(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
Dim btnClicked As Label = DirectCast(sender, Label)
Dim XY As Integer = Integer.Parse(btnClicked.Tag)
Dim cellX As Integer = XY \ 10
Dim cellY As Integer = XY Mod 10
btnX.Text = CStr(cellX)
btnY.Text = CStr(cellY)
Select Case btnZ.Text
Case "1", "2", "3", "4", "5", "6", "7", "8", "9"
cXY(cellX, cellY).Visible = True
cXY(cellX, cellY).Text = btnZ.Text
Case "N"
cXY(cellX, cellY).Text = " "
Case Else
End Select
drawSquare(cellX, cellY)
End Sub
Private Sub radioButtons(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles rb1.CheckedChanged, _
rb2.CheckedChanged, _
rb3.CheckedChanged, _
rb4.CheckedChanged, _
rb5.CheckedChanged, _
rb6.CheckedChanged, _
rb7.CheckedChanged, _
rb8.CheckedChanged, _
rb9.CheckedChanged, _
rbBlank.CheckedChanged
Select Case True
Case rb1.Checked
btnZ.Text = "1"
Case rb2.Checked
btnZ.Text = "2"
Case rb3.Checked
btnZ.Text = "3"
Case rb4.Checked
btnZ.Text = "4"
Case rb5.Checked
btnZ.Text = "5"
Case rb6.Checked
btnZ.Text = "6"
Case rb7.Checked
btnZ.Text = "7"
Case rb8.Checked
btnZ.Text = "8"
Case rb9.Checked
btnZ.Text = "9"
Case rbBlank.Checked
btnZ.Text = "N"
End Select
numTemplate.Text = btnZ.Text
End Sub
Private Sub exitBtn_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles exitBtn.Click
Application.Exit()
End Sub
Private Sub drawSquare(ByVal x As Integer, ByVal y As Integer)
bXY(x, y) = New Label
With bXY(x, y)
.Location = New System.Drawing.Point(299, 162)
.AutoSize = False
.BorderStyle = BorderStyle.FixedSingle
.Size = New System.Drawing.Size(3, 52)
.BackColor = Color.Black
.ForeColor = Color.Black
.Visible = True
End With
gbXY.Controls.Add(bXY(x, y))
btnX.Text = CStr(x)
btnY.Text = CStr(y)
bXY(1, 1) = New Label
With bXY(1, 1)
.Location = New System.Drawing.Point(500, 350)
.Size = New System.Drawing.Size(3, 52)
.BackColor = Color.Black
.ForeColor = Color.Black
End With
Me.Controls.Add(bXY(1, 1))
End Sub
End Class