Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:23:57+00:00 2026-06-15T18:23:57+00:00

I have a PictureBox, with an floor plan image. On that image I would

  • 0

I have a PictureBox, with an floor plan image.

On that image I would like to draw a polygon, which I can with the following code:

Private points As New List(Of Point)

Private Sub FlorPlan_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FlorPlan.MouseDown

points.Add(e.Location)
FlorPlan.Invalidate(New Rectangle(e.X, e.Y, 5, 5))
End Sub

Private Sub FlorPlan_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles FlorPlan.Paint
    For Each p As Point In points
        e.Graphics.FillRectangle(Brushes.Red, p.X, p.Y, 5, 5)
    Next
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim myPen As Pen
    myPen = New Pen(Drawing.Color.Red, 2)

    Dim myGraphics As Graphics = PictureBox.CreateGraphics
    myGraphics.DrawPolygon(myPen, points.ToArray)
    'myGraphics.FillPolygon(Brushes.Red, points.ToArray)
    myGraphics.Dispose()
End Sub

What I would like to do is to get hold of that object, so that I later can change the background color, etc.

How should I proceed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:23:59+00:00Added an answer on June 15, 2026 at 6:23 pm

    Their are two ways this would typically be done:

    • Manually keeping track of all your graphical objects in a list of some custom class.
    • Dynamically load a new control for each graphical object.

    If you choose to do the latter, I would recommend creating your own UserControl which contains all the necessary data about each graphical object, such as the points in the polygon. To dynamically load them, you could do something like this:

    Private Sub AddGraphicalObject(properties As GraphicalObjectProperties)
        Dim control As New GraphicalObjectControl()
        control.Properties = properties
        ' set position and size
        Panel1.Controls.Add(control)
    End Sub
    

    You will probably want to add some event handlers to some of the events on the control too as you add them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C# i have a picturebox. i would like to draw 4 colors. The
I have a control (picturebox), in which I want to draw an 2D image
I have a PictureBox control on a Form that is supposed to draw something
I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There
I would like to have a form in which the controls on the form
I have created a picturebox within my panel and I would like to fill
i have picturebox with picture cb. PBr1_1.Image = new Bitmap(@Logos\\Images\\cb.png); I'd like to change
I have a picturebox that has an image in it and a top of
I have a picturebox where i can load a image into its .backgroundimage function
I have a picturebox which displays an image of a music note. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.