Results 1 to 11 of 11

Thread: Button Visibility Implicitly Set to True, Somehow?

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Button Visibility Implicitly Set to True, Somehow?

    I have a button called cmdForceEdit on a tab called cntAudit.
    The button is only allowed for certain "access levels". I noticed this button is visible for everyone, however.
    There is an instruction when you click the Audit tab, that goes:
    Code:
            Case "Audit"
                cntAudit.Visible = True
                LoadJobChangeLog
                cntAudit.ZOrder
    Does setting the Visibility of the tab to True somehow trickle down to the button???
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Button Visibility Implicitly Set to True, Somehow?

    In design mode, set the initial Visible property to False.

    If that was already done, then your cntAudit_Click event is firing. You can place a breakpoint on the first line in that event and run your project. If the code stops there before your form completely loads and displays; then something in your startup code is activating that tab?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Button Visibility Implicitly Set to True, Somehow?

    Quote Originally Posted by LaVolpe View Post
    In design mode, set the initial Visible property to False.

    If that was already done, then your cntAudit_Click event is firing. You can place a breakpoint on the first line in that event and run your project. If the code stops there before your form completely loads and displays; then something in your startup code is activating that tab?
    Perhaps I'm missing something, but I'm not sure what that has to do with the visibility of the button on the tab.
    The button should be not visible, but when he makes the tab visible, the button shows up. That was the question, whether setting the container visible property somehow causes the child controls visible property to also be set to visible.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Button Visibility Implicitly Set to True, Somehow?

    Quote Originally Posted by passel View Post
    The button should be not visible, but when he makes the tab visible, the button shows up. That was the question, whether setting the container visible property somehow causes the child controls visible property to also be set to visible.
    Contained controls within SSTab, picturebox, and likely others, can be hidden and unhidden when their container is hidden/unhidden. But not if the control's visible state is False before the container is unhidden
    Code:
     ' add SSTab1 control to the form (can substitute with picturebox)
     ' place Command1 inside the control and leave its Visible property set to True
     ' add Command2 to the form and this:
    Private Command2_Click()
        SSTab1.Visible = Not SSTab1.Visible
        Debug.Print SSTab1.Visible, Command1.Visible
    
     ' Run project and click Command2 a couple times
     ' Now return to design view and change Command1 Visible property to False and try project again
    End Sub
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,937

    Re: Button Visibility Implicitly Set to True, Somehow?

    Passel, what tab control are you using?
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,937

    Re: Button Visibility Implicitly Set to True, Somehow?

    Hmmmm, I thought I had learned something new, but after playing with it, I remembered what the "got'cha is".

    You just get into trouble when you try and toggle (.Visible = Not .Visible) a control's visibility that's on a container that may also change visibility.

    Here's the "got'cha" situation. If a container is invisible (.Visible=False), all of its controls will also report as invisible according to their visibility properties. In other words, you can't "get at" the controls' true visibility property while the container is invisible.

    However, if you don't attempt to toggle, and just explicitly set it (.Visible = True --or-- .Visible = False), everything will work as expected. (So, a Let of the control's visibility property works fine. It's just the Get that gets spoofed if the container is invisible.)

    Basically, I think of the Visible properties of a container and the Visible properties of the controls on the container as totally independent. However, there's that one condition where, if the container is invisible, the controls will report as invisible, even if their true Visible property is True.

    Maybe That'll Help,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Button Visibility Implicitly Set to True, Somehow?

    Quote Originally Posted by Elroy View Post
    Passel, what tab control are you using?
    Not me, MMock.

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,937

    Re: Button Visibility Implicitly Set to True, Somehow?

    Ahhh, sorry. I didn't scroll up enough.

    MMock, if you come back to us, please tell us which tab control you're using.

    However, after taking a bit of time to study the situation, I don't think it matters. I'm fairly certain that, as I've outlined things in post #6, all container controls work the same way. I suspect the Get Visibility property of a control, when on a container, works something like the following:

    Reported Control's Visibility Property = Control.Visible And Container.Visible

    Whereas the Let just directly sets the control's property.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Re: Button Visibility Implicitly Set to True, Somehow?

    Quote Originally Posted by Elroy View Post
    Ahhh, sorry. I didn't scroll up enough.

    MMock, if you come back to us, please tell us which tab control you're using.
    LOL, no worries! This isn't even a "real" problem. I am porting this code from VB6 to .NET. In .NET, I was not showing this button to a user who is level 3 and she said she needs it. And I thought, that's odd, she didn't have it in VB6. Because just reading the code, I didn't see it getting shown to access levels below 4. But when I ran it at that access level, even as a 1, it was there! I had to carefully walk through the code and I found out the button became implicitly visible when the tab became explicitly visible. That's the code in post #1. So again, I'm not having an issue, I'll just do what's supposed to be done in .net, I just have a hard time understanding why it was working that way.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  10. #10
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,937

    Re: Button Visibility Implicitly Set to True, Somehow?

    Quote Originally Posted by MMock View Post
    I found out the button became implicitly visible when the tab became explicitly visible.
    From my experience, that still doesn't sound right to me. If, somewhere in the code, you're using a toggle of the button's visibility while the container is invisible, I can see it. But under any other circumstances, I don't see how that could happen.

    Here's what I mean by a toggle, including a look at the container's visibility:

    Code:
    If MyContainer.Visible = False Then MyButton.Visible = Not MyButton.Visible
    Regardless of the button's "true" visibility status, if the "Then" of that "If" statement executed , it would always make the button visible whenever you decided to show the container. That's the only way I can see how anything implicit could happen.

    Good Luck,
    Elroy

    p.s. We'll miss you over here in the true VB community. You do know that Microsoft is now abandoning the VB portion of .NET, right?
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  11. #11

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Re: Button Visibility Implicitly Set to True, Somehow?

    Yeah, I'll look at a little bit closer on Monday.
    Quote Originally Posted by Elroy View Post
    p.s. We'll miss you over here in the true VB community.
    I don't know if I ever actually was over here much but was very glad for this section when I had questions and for the supportive people.
    Quote Originally Posted by Elroy View Post
    You do know that Microsoft is now abandoning the VB portion of .NET, right?
    Um, that would be VB.NET? Are you *serious*???
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width