|
-
Nov 13th, 2006, 04:48 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] there must be another way (ToolStripDropDownButton)
Hi
I have a
- StatusStrip with a ToolStripDropDownButton
- ToolStripDownButton Property is set to "Image and Text"
- Resourcefile with to pictures (Pic1 and Pic2)
assign during designmode a Image from the resource file called Pic1 to the property Image
during the run this Image has to be changed so i did
VB Code:
if (dropdownbutton.Image.Equals(Resources.Pic1))
{
[INDENT]dropdownbutton.Image = Resources.Pic2;[/INDENT]
}
else
{
[INDENT]dropdownbutton.Image = Resources.Pic1;[/INDENT]
}
does not work.
i am using now this methode
the Tag Property of the ToolStripDropDownButton becomes during design time the value "0"
VB Code:
if (dropdownbutton.Tag.Equals("1"))
{
[INDENT]dropdownbutton.Tag = "2";[/INDENT]
[INDENT]dropdownbutton.Image = Resources.Pic2;[/INDENT]
}
else
{
[INDENT]dropdownbutton.Tag = "1";[/INDENT]
[INDENT]dropdownbutton.Image = Resources.Pic1;[/INDENT]
}
There must be a better way ???
thx
Last edited by Bongo; Nov 15th, 2006 at 07:10 AM.
Reason: Changing Resolved Icon
-
Nov 13th, 2006, 06:32 AM
#2
Frenzied Member
Re: there must be another way (ToolStripDropDownButton)
It is working right now? You just want it better? Better how? Shorter? No IF?
-
Nov 13th, 2006, 07:05 AM
#3
Thread Starter
Hyperactive Member
Re: there must be another way (ToolStripDropDownButton)
no i thing if an object has the methode equal (which i thing is to compare) there should be a way to say Image.Equal(image) should work. It works with other objects.
So i believe if did a workaround but i did not solve the real issue.
-
Nov 13th, 2006, 08:45 AM
#4
Thread Starter
Hyperactive Member
Re: there must be another way (ToolStripDropDownButton)
Or lets rephrase
WHY does
if(TooStripDropDownButton.Image.Equal(Resources.Image))
not work???
-
Nov 13th, 2006, 04:33 PM
#5
Re: there must be another way (ToolStripDropDownButton)
 Originally Posted by Bongo
Or lets rephrase
WHY does
if(TooStripDropDownButton.Image.Equal(Resources.Image))
not work???
Because each time you get that property from your resources you get a new Image object. If you get the property twice then your creating two distinct Image objects so they are not equal. You should only be getting each resource once each. Assign them to variables and compare to those variables.
-
Nov 14th, 2006, 02:18 AM
#6
Thread Starter
Hyperactive Member
Re: there must be another way (ToolStripDropDownButton)
Because each time you get that property from your resources you get a new Image object. If you get the property twice then your creating two distinct Image objects so they are not equal. You should only be getting each resource once each. Assign them to variables and compare to those variables.
Hi jmcilhinney,
so if i would write
Image img1 = TooStripDropDownButton.Image;
Image img2 = Resources.Pic1;
if (img1.Equal(img2))
it should work. (cant try it in the moment - not an a developing comp)
If it works it would look better then the thingi with the tag.
thx
Last edited by Bongo; Nov 14th, 2006 at 02:21 AM.
-
Nov 14th, 2006, 06:56 AM
#7
Thread Starter
Hyperactive Member
Re: there must be another way (ToolStripDropDownButton)
 Originally Posted by Bongo
Image img1 = TooStripDropDownButton.Image;
Image img2 = Resources.Pic1;
if (img1.Equal(img2))
Tryed it - did not work
-
Nov 14th, 2006, 04:50 PM
#8
Re: there must be another way (ToolStripDropDownButton)
Declare two class-level Image variables. Get your resource images once only and assign them to those variables. Now you ONLY set the Image property of your button from those variables and you ONLY compare the Image property of your button to those variables. Also, just use the '==' operator to compare two reference type objects.
-
Nov 15th, 2006, 02:42 AM
#9
Thread Starter
Hyperactive Member
Re: there must be another way (ToolStripDropDownButton)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|