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

Ouch. I am embarassed by how long it took to dawn on me that the code shown here
is just about useless without the relevant Design elements.
( By the way, is it possible to send an entire folder to a daniweb thread ? )

That said, with 20-20 hindsight the obvious ( but previously missing ) question was :
what exactly was the point of the groupbox ?

Anyway, I deleted that from the Design.
( The problem then was having to be particularly careful about drawing the lines
representing cell borders. )

Pleasantly surprised to say that actually worked.

So my original question stands, but is now merely hypothetical.

( For me this has been one of those seemingly insoluble problems
where the very fact of explaining it in detail to others
somehow helps you see the solution. )

Thanks

You probably don't want to post your entire app here unless you don't mind someone else potentially stealing your work.

You named your variables well and it shouldn't be too hard to figure out. I'll get back to you shortly.

Well, I got the app up and running. I get a grid of lables (9x9) in the group box. I then select one of the radio buttons (1-9 + blank). When I then click one of the labels in the group box, I get the appropriate integer, or blank. The buttons (x and Y) change text to display the coordinates of the label clicked. The third button displays the integer selected by the radio button.

I did notice that in the DrawSquare method that you are creating two new labels (BXY(X,y), and BXY(1,1)) then adding one to the group box controls and the other to the forms controls (Me.controls.add). Is this intentional? Also, the second label is set to a static location of (500,350). Again, is this intentional?

Edit: Actually both of those previously mentioned labels are set to static locations. Looks like they are behind the previously added labels. You might want to "BringToFront".

Edited 5 Years Ago by CodeWord: n/a

CodeWord : thanks for your reply. Encouraging to know that SOMEBODY is interested in what I write.

But the first point to make here is that I am keying this on a machine WITHOUT access to Visual Basic.

As for DrawSquare, where to begin ?

It was a 'draft' of a means of drawing squares around particular cells on the Form.
Lines 86 - 96 define a 'Label' whose Location is INSIDE the groupbox.
Note its Size : (3,52) ; that is : a thick line rather than a rectangle ( and, yes, that is what I want ).
( VB.Net does not allow Linespace definitions in code ).
Similarly lines 99-106. The difference here though is that the Location is OUTSIDE the groupbox.

Now judging by both the Size parameters ( each being (3,52) ), you would thiink that the result of that method
executing would be two parralel lines of the same length and thickness.

However for some reason neither my boss nor I understand, the line INSIDE the groupbox appears thinner.
( I do not know if that happens WITHOUT the Designer elements of that code. )

But I am now on Plan B ( which has its own problem ) and that problem is now academic.

This question has already been answered. Start a new discussion instead.