[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?
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
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
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.
Re: [RESOLVED] [2005] Button Toggles after performing action
Re: [RESOLVED] [2005] Button Toggles after performing action
Quote:
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.
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
Re: [RESOLVED] [2005] Button Toggles after performing action
Quote:
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? :blush: