?
Solved

PictureBox.Tag treated as Integer

Posted on 2010-01-10
2
Medium Priority
?
841 Views
Last Modified: 2012-05-08
Hello experts,

i have PictureBox on my form, as Tag I typed 1.

How can I retrieve the one value as integer?

I tried:

int i = (int)PictureBox.Tag;

but it didn't work.

thx

panJacek
0
Comment
Question by:panJacek
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1880 total points
ID: 26277684
Things added to the Tag() property via the IDE are actually STRINGS so you need to parse it back to an integer:

            int i;
            if (int.TryParse((string)PictureBox.Tag, out i))
            {
                // ...now do something with "i"...
                MessageBox.Show(i.ToString(), "i");
            }
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 120 total points
ID: 26278576
Small distinction is that the Tag property is inherited from the System.Windows.Forms.Control class, and is an Object with a StringConverter as a TypeConverter.


[Bindable(true), SRCategory("CatData"), SRDescription("ControlTagDescr"), DefaultValue((string) null), Localizable(false), TypeConverter(typeof(StringConverter))]
public object Tag
{
    get
    {
        return this.Properties.GetObject(PropUserData);
    }
    set
    {
        this.Properties.SetObject(PropUserData, value);
    }
}

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question