Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Visible/Invisible Buttons - Frames ?

Status
Not open for further replies.

AlisonEmmett

Technical User
Sep 8, 2000
15
0
0
GB
I have a from which displays 20 buttons if a certain criteria is met, and 20 different buttons if it isn't.
At the moment I'm doing this via the OnCurrent Property and an if statement followed by lines and line of code setting the visible property of each button to True or False.
Is there a way to make a section of the form (a frame ?) Visible or Invisible - thus rendering all the buttons in that frame visible/invisible with one line of code ?

Thanks for any help....
 
Slightly different approach, but you could use the TabControl. It offers the advantage that the schema could be extended to a large number of groups. Just 'set' the tab based on your criteria.

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Thanks - looks good - can overlay one tab control over another and put all the buttons on them - then just turning the control invisible does the same for all the buttons (essentially)
 
Allison,

Not QUITE what I had in mind. The TabControl may have a number of "pages". Only one "Page" or Tab is visible at a time. You may select the visible tab normally via the "_Click" event of the Tab, or (my suggestion) set it in code.

Place your cmdButton Groups on seperate tabs of the same TabControl. If you dont want users to be able to select the alternate set of cmdButtoms, just set the Tab height to 0. Then is is (almost) impossible to get the "_Click" event ==> You can set the group available to the user.


MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Michael - I did understand your way - but thought that mine would be a little easier to action from the starting point I'm at.
Are you saying my way (overlaying the tab controls and just switching certain ones to visible) won't work ?
 
It should work, but in the long run it will probably not be any easier. You will need to be very careful about the size/position of the two controls, other wise the 'Image" will flicker when you switch. Plus, to do it with two controls, you need more logic/code:

If (MyCondition) then
[tab]Control1.Visible = True
[tab]Control2.Visible = Not Control1.visible
Else
[tab]Control2.Visible = True
[tab]Control1.Visible = Not Control2.visible
End If

_______________________ OR _____________________

[tab]TabControl.Tab = Abs(MyCondition)

Of course, the above depends on the "trick" of having only the two conditions, with the first being the False, and the second being "true", so the abs(XXX) evaluates to either FALSE (0) or TRUE (1), corresponding to tabs 0 and 1 respectively. thus here, one line of code - without any logical/branch calculations replaces the seven lines with the branch.

More complex processing page arrangements would depend on MyCondition being evaluated to an integer.

It should not be any harder to copy the controls to the two pages of the single tab control than to copy the same number of controls to two seperate tab controls. If I am missing something, popease let me know.




MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
My only reticence is that I don't know the code

I have a test as follows:

If test then variable = 1
Else variable = 0

I have a tabcontrol with two pages ( call them page0 and page1)

If variable = 1 I want to see page1 and page0 be inaccessible
If variable = 0 I want to see page0 and page1 be inaccessible.

I want to use the oncurrent function, but I'm not sure what the code would be to make all this work

Thanks

Al
 
Al, The "Code" should (usually) be where ever the 'test' variable is set. Unless this is not 'in' the same form. If 'test' is not set in the same form, then you do need to do some additional work, but what this is depends on some details.

I do not know why you are thinking of putting the code in the "onCurrent" event. Usually, this is to set up for each change in the record which is shown on the form. If this is your intent, then the OcCurrent event is appropiate. Of course, this assumes that 'test' may change with each record displayed.

[tab]If (Test) Then
[tab][tab]TabControl.Pages(1).SetFocus
[tab] Else
[tab][tab]TabControl.Pages(0).SetFocus
[tab]End If

alternatively,

[tab]TabControl.Pages(Abs(Test)).SetFocus

Will accompllish the same - with a little less work (Code) - at the expense of assuming "test" is a boolean and limiting the pages which are set to the first two (0 and 1).

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Thankyou - obvious when you know how - but can't find it in the help for love or money. I do need to run the test on each record - so it is perfect

thanks again
 
another technical note thrown in:
The value of a TabControl's .Value property is always equal to the .PageIndex property of its currently displayed page (what you call "tab" above). And the .Value property is Read/Write.

From now on, I'll refer to a specific TabControl with the name tabMyTabControl. Obviously, you can name yours whatever you want ;-) .

You can change the displayed page by setting tabMyTabControl.Value. So tabMyTabControl.Value = 1 displays (and sets the focus to) tabMyTabControl.Pages(1) (because tabMyTabControl.Pages(1).PageIndex is equal to 1).

This also lets you find out which page is currently displayed by checking the value of tabMyTabControl.Value. And you can refer to the current page without already knowing which one it is, by using tabMyTabControl.Pages(tabMyTabControl.Value) -- C Vigil =)
(Before becoming a member, I also signed on several posts as
"JustPassingThru" and "QuickieBoy" -- as in "Giving Quick Answers")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top