|
-
Feb 1st, 2005, 11:03 PM
#1
Thread Starter
Hyperactive Member
Picturebox click event handling. (Resolved)
I want to have each click on the picturebox do something according to which click it is. The first will set the box to 3d border, the next will set it back to no border.
I thought for sure this would work:
VB Code:
Private Sub pbxDieOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pbxDieOne.Click
If clickCntrD1 = 0 Then
clickCntrD1 += 1
pbxDieOne.BorderStyle = pbxDieOne.BorderStyle.Fixed3D
'next the image will become a blank die so we can tell which dice we have chosen to change
End If
If clickCntrD1 = 1 Then
pbxDieOne.BorderStyle = pbxDieOne.BorderStyle.None
'next the image will become a blank die so we can tell which dice we have chosen to change
clickCntrD1 = 0
End If
But alas, the picturebox's border doesn' change. The picturebox's border will change if I have only one action for it to take, like just make the picturebox's border 3d when someone clicks on it. But I want the person to be able to click on the picturebox again to reset it.
THank you in advance.
Last edited by gjon; Feb 2nd, 2005 at 12:00 AM.
-
Feb 1st, 2005, 11:49 PM
#2
Re: Picturebox click event handling.
The best way to handle this is based on the current border style...
VB Code:
Select Case pbxDieOne.BorderStyle
Case BorderStyle.None
pbxDieOne.BorderStyle = BorderStyle.FixedSingle 'If you dont want fixed single comment-out this line
Case BorderStyle.FixedSingle ' And this line
pbxDieOne.BorderStyle = BorderStyle.Fixed3D
Case BorderStyle.Fixed3D
pbxDieOne.BorderStyle = BorderStyle.None
End Select
Last edited by <ABX; Feb 1st, 2005 at 11:52 PM.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Feb 1st, 2005, 11:51 PM
#3
Thread Starter
Hyperactive Member
Re: Picturebox click event handling.
That is an excellent idea. I will give that a go.
I am curious tho, why won't the way I tried it work?
-
Feb 1st, 2005, 11:55 PM
#4
Re: Picturebox click event handling.
VB Code:
If clickCntrD1 = 0 Then
[b]clickCntrD1 += 1[/b]
pbxDieOne.BorderStyle = pbxDieOne.BorderStyle.Fixed3D
'next the image will become a blank die so we can tell which dice we have chosen to change
End If
[b]If clickCntrD1 = 1 Then[/b]
pbxDieOne.BorderStyle = pbxDieOne.BorderStyle.None
'next the image will become a blank die so we can tell which dice we have chosen to change
clickCntrD1 = 0
End If
Your way is underminding it self... if you look at the bolded areas you will notice that you set the value to 1 then the next bolded statement is true so then it sets the border style back.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Feb 1st, 2005, 11:56 PM
#5
Re: Picturebox click event handling.
I fixed your code here:
VB Code:
If clickCntrD1 = 0 Then
clickCntrD1 += 1
pbxDieOne.BorderStyle = pbxDieOne.BorderStyle.Fixed3D
'next the image will become a blank die so we can tell which dice we have chosen to change
Else
pbxDieOne.BorderStyle = pbxDieOne.BorderStyle.None
'next the image will become a blank die so we can tell which dice we have chosen to change
clickCntrD1 = 0
End If
Last edited by <ABX; Feb 1st, 2005 at 11:57 PM.
Reason: Did i mention that i hate this editor :P
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Feb 1st, 2005, 11:59 PM
#6
Thread Starter
Hyperactive Member
Re: Picturebox click event handling.
Ahhh, yes I see now what I did. It's not going to run one if and then exit the procedure, it will go to the next if right afterwards.
Yes now I see why it should work. I need else if.
Thanks for letting me see how that works better. I understand so much better now.
Cheers
Last edited by gjon; Feb 2nd, 2005 at 01:10 AM.
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
|