Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15705

VS 2017 Drawing on Pictureboxes on FlowLayoutpanel

$
0
0
I know I ask odd questions, and my VB skills are bad. I haven't really done much since VB6 (we're talking mid 90's). I'm working on a program for myself for work that calculates wall panel sizes and creates really simple drawings for installers. I'm using flowlayoutpanel because it suites my needs just fine without having to figure out graphics. You enter the number of panels, the width, and the height and it displays a representation on a Panel. (Thanks to borderstyle)
Name:  flpexample.png
Views: 18
Size:  7.7 KB
That is actually good enough but i was thinking of adding a simple line and rectangle drawing ability, but can't figure out how to draw on a runtime created control. I've tried adding Addhandlers for mouse events (based on my searches), but I'm not sure how to do that.
Code:

Private Sub GProwsPB(ByVal PanelsX As Integer)
        Dim psw As Integer = TBWidth.Text * 2.4

        Dim psh As Integer = TBHeight.Text * 2.4

        Dim lbw As Integer = psw - 10
        Dim lbh As Integer = psh / 2

        For i As Integer = 1 To PanelsX
            Dim fl As New PictureBox

            fl.Size = New Size(psw, psh)
            fl.BackColor = Color.White
            fl.Margin = New Padding(0)

            fl.BorderStyle = BorderStyle.FixedSingle
            fl.Cursor = Cursors.Hand
            fl.AllowDrop = True
            'AddHandler fl.MouseDown, AddressOf MouseXDown
            'AddHandler fl.MouseMove, AddressOf MouseXMove
            'AddHandler fl.MouseUp, AddressOf MouseXUp
            Dim lbl As New Label
            Dim lblSize As New Label
            lbl.Text = TBLabel.Text & vbNewLine & TBPanelSize.Text
            lbl.AutoSize = False
            lbl.Size = New Size(lbw, lbh)
            lbl.Anchor = AnchorStyles.None
            lbl.TextAlign = ContentAlignment.BottomCenter
            fl.Controls.Add(lbl)

            FlpPanels.Controls.Add(fl)
        Next
    End Sub

That sloppy code draws my pictureboxes and I would like to be able to then draw on them. Afterwards I just save the parent panel as an image file. I could post the code I tried for the mouse events but you might just laugh at me :). It could even draw in front of the pictureboxes if that doesn't effect how drawtobitmap works. Is this even possible? Any examples would be much appreciated. Thanks
Attached Images
 

Viewing all articles
Browse latest Browse all 15705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>