473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Return name of image in a picturebox

I have a list of images in the resource file of a VB project and a particular picture box on my form gets populated with an image depending on certain conditions:
Expand|Select|Wrap|Line Numbers
  1. picNotify.Image = My.Resources.[ImageName] 
Later on in my program I want to query the name of the image in the picturebox. Technically I could create a variable and pass the name of the image in the same piece of code above but I dont like creating unnecessary variables if I am able to extract the information via code.

Is this possible?
Jan 7 '09 #1
4 8639
MrMancunian
569 Expert 512MB
You can use sender in the Click_Event.

I didn't test it but it should be something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub picPicturebox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picPicturebox.Click
  2.   Dim picTempPicturebox As Picturebox = sender
  3.   Msgbox(sender.Name)
  4. End Sub
  5.  
Steven
Jan 9 '09 #2
Sorry that does not work. The name of my picture box is called picNotify and that part of your code returns "picNotify".
I need the name of the image contained in the picture box

Thanks for trying though, appreciate it.
Jan 10 '09 #3
MrMancunian
569 Expert 512MB
How about sender.Image then?

Steven
Jan 10 '09 #4
Afraid not.
The code you gave me isnt necessary because I can access all the same options by just calling the name of the picture box. I cannot find the actual name of the picture being used anywhere at all in the code.

Have a go yourself......start a blank project (windows form), add a picture box, assign it any picture at all and then see if you can find the name of the picture from run-time.

Also as a help, if you do :
Expand|Select|Wrap|Line Numbers
  1.  msgbox (picBox)
where picBox is the name of your picture box control, then it will go to debugging mode. You can highlight the picture box to show all list of properties and I still can't find the name. Its driving me a bit mad!!
Jan 15 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: AJ | last post by:
Hi, I have 20 pictureBoxes named from PictureBox1 to PictureBox20. I want to fill them up one by one. I'm keeping a variable firstAvail to keep up with which pictureBox I should insert the next...
3
by: Isz | last post by:
I can do this easily enough in actionscript, but I would like to do it also in C#. I have 10 Image controls on the .aspx page. I want to create a loop that makes the first 'n' number of Images'...
1
by: marco | last post by:
I'm a newbie and i'm doing a little application that open image. I don't understand what i've to do to have a zoom of an image...i don't know where's the error. If anyone know a simple code tell me...
2
by: marco | last post by:
I'm a newbie and i'm doing a little application in C# for a Pocket PC that open image. I don't understand what i've to do to have a zoom of an image...i don't know where's the error. If anyone...
6
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
4
by: John Swan | last post by:
Hello. I'm trying to create a simple program that amongst other things creates a thumbnail of an image (Bitmap) to a set size determined by the user in pixels? The problem is: All of the...
3
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.