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

  • Home
  • SEARCH
  • 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 6839267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:41:54+00:00 2026-05-26T23:41:54+00:00

After taking a few years off from programming, I decided to start learning vb.net.

  • 0

After taking a few years off from programming, I decided to start learning vb.net. I have created a user control that contains a picture box. I added some custom properties to the picture box that will hold general string data from a database.

My problem is that the user control is programatically created during run time, and during this time a DoubleClick event handler is added for the picture box that is within the user control.

I need to be able to set the custom properties for the picture box during the creation of the user control, so that when the control (picture box) is double clicked I can read these values but am unsure on how to access them.

The picture box is the entire size of the user control, or I would just add the custom properties right to the user control and add the DoubleClick event handler to that. However, double clicking needs to be done on the picture box since it takes up the entire user control, unless anyone has an idea to trigger the DoubleClick event of the user control when the picture box is double clicked.

Here is a bit of code I am using to add the user control to the form programatically –

hb_item = New PictureLoader

With hb_item
    .Name = "item_" & i
    .Left = itemLeft
    .Top = itemTop
    .SetImageSizeMode = ImageLayout.Stretch
    .SetLoadingImageSizeMode = ImageLayout.Stretch
    .Size = New Size(100, 126)
    .SetImage = BlobToImage(sql_reader("ThumbImage"))
    .Visible = True
    .SetHighlight(True)
    .SetHighlightColor = Color.GreenYellow
    .TextColor = Color.White
    .CircleColor = Color.GreenYellow

    '--- THIS UPDATES ONE OF THE CUSTOM PROPERTIES FOR THE PICTURE BOX
    '--- CONTAINED WITHIN THE USER CONTROL
    .SetID = "test"

    AddHandler .picMainClick, AddressOf frmHome.HBItem_Click
    AddHandler .picMainDoubleClick, AddressOf frmHome.HBItem_DoubleClick
End With

Here is the event handler code I am trying to access the picture box’s custom properties from

Public Sub HBItem_DoubleClick(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.DoubleClick

    With sender
        '--- THIS IS WHERE I WANT TO READ THE DATA IN THE CUSTOM PROPERTIES 
        '--- OF THE PICTURE BOX... SOMETHING SIMILAR TO THE FOLLOWING -

        ' Database_ID is one of the custom properties of the sender (picMain 
        ' control on the user control)
        MessageBox.Show(.Database_ID) 
    End With
End Sub

EDIT: Got it all worked out, thanks for everything. All that was needed was casting the sender to the actual picture box like stated, I was just looking way to deeply into things. A simple one line of code is all that was needed in the event handler –

Dim pb As xPictureBox = CType(sender, xPictureBox)

Then all the custom properties could be accessed using pb.property_here.

  • 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-05-26T23:41:55+00:00Added an answer on May 26, 2026 at 11:41 pm

    sender is of type System.Object – you need to cast (convert) sender to the type it actually is (in your case, your custom user control), i.e.:

    Dim myControl As MyCustomControl = CType(sender, MyCustomControl)
    
    With myControl
        MessageBox.Show(.Database_ID)
    End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few related questions. I am new to Rails 3 after taking
After taking some small courses and using WPF and C# a bit I've decided
We have created a multi-threaded application which process/parse big files (few hundred MB's) simultaneously.
After taking a look at this SO question and doing my own research, it
When I go back to school after Thanksgiving, I'll be taking a course in
After being told by at least 10 people on SO that version control was
After lots of attempts and search I have never found a satisfactory way to
Well I have a few questions and I like to make sure I am
I have a SQL Server database and I'm using ADO.NET ExecuteReader to get a
After reading (nearly) the whole ebook and taking a look at the API i

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.