Dim cdlg As New ColorDialog()
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
Dim gr As Graphics = RichTextBox1.CreateGraphics()
Dim myBrush As SolidBrush = New SolidBrush(cdlg.Color)
Dim myPen As Pen = New Pen(myBrush, 1)
If TxtRow.Text = "" Or TxtColumn.Text = "" Or TxtRow.Text = "0" Or TxtColumn.Text = "0" Then
Return
End If
Dim linesRow As Integer = Convert.ToInt32(TxtRow.Text)
Dim linesCol As Integer = Convert.ToInt32(TxtColumn.Text)
Dim x As Single = 0.0F
Dim y As Single = 0.0F
Dim xSpace As Single = ((RichTextBox1.Width - myPen.Width) * 1.0F / linesRow)
Dim ySpace As Single = ((RichTextBox1.Height - myPen.Width) * 1.0F / linesCol)
Dim nn As Integer = IIf(RichTextBox1.Width <= RichTextBox1.Height, xSpace / 4, ySpace / 4)
Dim myFont As New Font("Arial", nn)
''// Vertical Lins
For i = 0 To linesRow
gr.DrawLine(myPen, x, y, x, ySpace * linesRow)
gr.DrawLine(myPen, x, y, x, ySpace * linesCol)
x += xSpace
Next
''// Horizontal Lins
x = 0.0F
y = 0.0F
For i = 0 To linesCol
gr.DrawLine(myPen, x, y, xSpace * linesCol, y)
gr.DrawLine(myPen, x, y, xSpace * linesRow, y)
y += ySpace
Next
''Text
x = 0.0F
y = 0.0F
Dim counter As Integer = 1
For r = 0 To linesCol
For c = 0 To linesRow
gr.DrawString(counter.ToString(), myFont, myBrush, x, y) '';//x+ myFont.Size//y + myFont.Size
''gr.DrawString(counter.ToString(), myFont, Brushes.Black, x + myFont.Size, y + myFont.Size)
x += xSpace
Next
''//gr.DrawString(counter.ToString(), myFont, Brushes.Black, x + myFont.Size, y + myFont.Size);
counter += 1
y += ySpace
x = 0
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RichTextBox1.Refresh()
End Sub