Results 1 to 9 of 9

Thread: How do you create a command that hides each label on the surface of the form?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2021
    Posts
    257

    Question How do you create a command that hides each label on the surface of the form?

    -----------------------------------
    Attached Images Attached Images  

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: How do you create a command that hides each label on the surface of the form?

    Code:
    Label.Visible = False
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2021
    Posts
    257

    Re: How do you create a command that hides each label on the surface of the form?

    Quote Originally Posted by Zvoni View Post
    Code:
    Label.Visible = False
    Thank you
    I know that, but I want one thing that hides everyone

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: How do you create a command that hides each label on the surface of the form?

    There is no "one thing that hides everything".
    you have to iterate either through
    a) your Control-Array of Labels, setting each Member to invisible
    b) the Control-Collection of the Form containig all Controls, check for Type "Label", then make it invisible

    ....and in my answer are some hints hidden for you.....
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

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

    Re: How do you create a command that hides each label on the surface of the form?

    You can put the labels in a borderless frame, and then set the frame to not be visible which will hide all the controls parented in the frame.
    Last edited by passel; Jun 27th, 2022 at 10:57 AM.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2021
    Posts
    257

    Re: How do you create a command that hides each label on the surface of the form?

    Quote Originally Posted by Mysystem View Post
    Thank you
    I know that, but I want one thing that hides everyone
    Thank you

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2021
    Posts
    257

    Talking Re: How do you create a command that hides each label on the surface of the form?

    Quote Originally Posted by passel View Post
    You put the labels in a borderless frame, and then set the frame to not be visible which will hide all the controls parented in the frame.
    Thank you

  8. #8
    Addicted Member
    Join Date
    Oct 2011
    Posts
    179

    Re: How do you create a command that hides each label on the surface of the form?

    Code:
    Private Sub Command1_Click()
        ShowControlType "Label", False
    End Sub
    
    Private Sub ShowControlType(ControlType As String, ShowControl As Boolean)
        Dim c As Control
        For Each c In Controls
            If TypeName(c) = ControlType Then c.Visible = ShowControl
        Next
    End Sub

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2021
    Posts
    257

    Red face Re: How do you create a command that hides each label on the surface of the form?

    Quote Originally Posted by argen View Post
    Code:
    Private Sub Command1_Click()
        ShowControlType "Label", False
    End Sub
    
    Private Sub ShowControlType(ControlType As String, ShowControl As Boolean)
        Dim c As Control
        For Each c In Controls
            If TypeName(c) = ControlType Then c.Visible = ShowControl
        Next
    End Sub
    Thank you

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