|
-
Oct 5th, 2008, 06:41 PM
#1
Thread Starter
Lively Member
[RESOLVED] [2005] Button Toggles after performing action
The current program i am working has a rather large GUI. I'm trying to tone it down by making a button preform the opposite action after it has been clicked.
In my case i want the button to
Code:
tabcontrol1.sendtoback()
and after being clicked and sending it to back change to
Code:
tabcontrol1.bringtofront()
And so forth every time the button is clicked it will change to the opposite reaction.
Has anyone done this before?
-
Oct 5th, 2008, 07:03 PM
#2
Re: [2005] Button Toggles after performing action
Hey,
You could create a variable at a top level scope, and you the click of your button:
Code:
If myVariable = False Then
tabcontrol1.sendtoback()
myVariable = True
Else
tabcontrol1.bringtofront()
myVariable = False
End If
Hope that helps!!
Gary
-
Oct 5th, 2008, 07:07 PM
#3
Re: [2005] Button Toggles after performing action
i'd use a static variable within the button_click event
vb Code:
static myVariable as boolean = False
If myVariable = False Then
tabcontrol1.sendtoback()
myVariable = True
Else
tabcontrol1.bringtofront()
myVariable = False
End If
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 6th, 2008, 08:49 AM
#4
Re: [RESOLVED] [2005] Button Toggles after performing action
What do BringToFront and SendToBack do? They adjust the z-index of the control. You simply need to check whether the z-index of the TabControl is zero or not. If it is then call SendToBack. If it's not then call BringToFront. The z-index of a control is its index in its container's Controls collection:
vb.net Code:
If Me.Controls.IndexOf(Me.TabControl1) = 0 Then Me.TabControl1.SendToBack() Else Me.TabControl1.BringToFront() End If
That's untested but I can't see why it wouldn't work.
-
Oct 6th, 2008, 09:20 AM
#5
Lively Member
Re: [RESOLVED] [2005] Button Toggles after performing action
-
Oct 6th, 2008, 06:37 PM
#6
Re: [RESOLVED] [2005] Button Toggles after performing action
 Originally Posted by youthbytes
nvm... already resolved.
I realised that from the "[RESOLVED]" in the thread title but I was trying to provide some useful information to improve your understanding of what was happening.
-
Oct 6th, 2008, 06:50 PM
#7
Re: [RESOLVED] [2005] Button Toggles after performing action
Hey,
I don't think that post was aimed at you jm, the way I read that was that youthbytes was going to suggest something, and then decided not to as he/she realized that the thread was already resolved. I could be wrong, but I don't think anything was meant by it 
Gary
-
Oct 6th, 2008, 07:00 PM
#8
Re: [RESOLVED] [2005] Button Toggles after performing action
 Originally Posted by gep13
Hey,
I don't think that post was aimed at you jm, the way I read that was that youthbytes was going to suggest something, and then decided not to as he/she realized that the thread was already resolved. I could be wrong, but I don't think anything was meant by it
Gary
Ah, it appears you're correct. I assumed it was the OP posting that. Should look a bit closer, shouldn't I?
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
|