Home All Groups Group Topic Archive Search About

Draw Line in a specific picturebox

Author
14 Aug 2006 9:47 PM
Alejandro
Hi,

I Have a form with Collection of 52 picturebox.

    Public cl As New Collection
    Private m_Bitmap As Bitmap

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

        Dim i As Int32

        For i = 1 To 52
            m_Bitmap = New
Bitmap(System.Drawing.Image.FromFile("C:\diente40x40.bmp"))
            cl.Add(m_Bitmap, i.ToString())
        Next i

    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        Dim posx As Integer = 0
        Dim posy As Integer = 0
        For i As Integer = 1 To 52

            e.Graphics.DrawImage(cl(i), posx, posy)
            posy = posy + 20
            posx = posx + 40

        Next
    End Sub

I need draw a line in a specific picturebox, for example:

In a combobox select 25, then draw a line in a bitmap 25, how make
this??

tks 4 ur help

Author
14 Aug 2006 11:59 PM
GhostInAK
Hello Alejandro,

I think if it were me, given the code you have just posted.. I would maintain
an array of 52 bytes.  These bytes would contain either a 0 or a 1.  On your
loop through the bitmap collection in your form paint event check the index
of the byte array.  If 0, do nothing, if 1, draw a line.  You already know
the coordinates of the bitmap, so drawing the line is trivial.

-Boo

Show quoteHide quote
> Hi,
>
> I Have a form with Collection of 52 picturebox.
>
> Public cl As New Collection
> Private m_Bitmap As Bitmap
> Private Sub Form1_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> Dim i As Int32
>
> For i = 1 To 52
> m_Bitmap = New
> Bitmap(System.Drawing.Image.FromFile("C:\diente40x40.bmp"))
> cl.Add(m_Bitmap, i.ToString())
> Next i
> End Sub
>
> Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
> System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
>
> Dim posx As Integer = 0
> Dim posy As Integer = 0
> For i As Integer = 1 To 52
> e.Graphics.DrawImage(cl(i), posx, posy)
> posy = posy + 20
> posx = posx + 40
> Next
> End Sub
> I need draw a line in a specific picturebox, for example:
>
> In a combobox select 25, then draw a line in a bitmap 25, how make
> this??
>
> tks 4 ur help
>