GRIDLINE EM PICTUREBOX

FROSTYNHO 04/06/2011 17:50:23
#375861
qual a melhor forma de criar uma gridline (grade) no picturebox? estou usando a seguinte forma:
    Dim GridSize As New Size(16, 16)
Dim GridColor As Color = Color.White
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
ControlPaint.DrawGrid(e.Graphics, e.ClipRectangle, GridSize, GridColor)
End Sub

mas desta forma nao aparece as linhas... aí fiz desta forma:
Public SlicePen As Pen
Public SlicePenSize As Integer = 1
Public SlicePenDashStyle As Drawing2D.DashStyle = Drawing2D.DashStyle.Solid
Public SlicePenColor As Color = Color.Yellow

Dim iWidth As Integer = 16
Dim iHeight As Integer = 16
for i = 0 to 6
for j = 0 to 7
PictureBox1.CreateGraphics.DrawRectangle(SlicePen, iWidth * i, iHeight * j, iWidth, iHeight)
next j
next i

mas assim fica muito pesado... alguem tem uma ideia de como criar? des de ja muito obrigado pessoal!
FROSTYNHO 17/06/2011 16:05:53
#377122
ninguem?
FROSTYNHO 19/07/2011 10:07:34
#379518
alguem?
RODRIGOFERRO 19/07/2011 10:28:22
#379520
Resposta escolhida
em C# eu faria assim...



private void pictureBox1_Paint(object sender, PaintEventArgs e)
{

// Drawing vertical lines
for (int x = 5; x < this.ClientRectangle.Width; x += 5)
{
e.Graphics.DrawLine(Pens.Gray, new Point(x, 0), new Point(x, this.ClientRectangle.Height));
}

// Drawing horisontal lines
for (int y = 5; y < this.ClientRectangle.Width; y += 5)
{
e.Graphics.DrawLine(Pens.Gray, new Point(0, y), new Point(this.ClientRectangle.Width, y));
}

}



só nao me peça para converter ahaihaiuahiau..

Abraços
FROSTYNHO 19/07/2011 10:31:16
#379521
kkkkkkkk, já converti para vb.net, se alguem precisar... taí:


For x As Integer = 5 To Me.ClientRectangle.Width - 1 Step 5
e.Graphics.DrawLine(Pens.Gray, New Point(x, 0), New Point(x, Me.ClientRectangle.Height))
Next

For y As Integer = 5 To Me.ClientRectangle.Width - 1 Step 5
e.Graphics.DrawLine(Pens.Gray, New Point(0, y), New Point(Me.ClientRectangle.Width, y))
Next
Tópico encerrado , respostas não são mais permitidas