Results 1 to 11 of 11

Thread: How To Hide a Control With Solid Colour - What Properties?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    15

    How To Hide a Control With Solid Colour - What Properties?

    Good Evening

    I have tried this in VB6 but I am still not 100 percent sure if this right-

    I want a control on the form to have a solid colour that won't show through the colour of the form it is placed on.

    This is what I think is done to achieve this:

    Modify STYLE Property – Set to 1 – Graphical, which turns the control into the same colour as the background

    Modify VISIBLE Property – Set to False which sets a value to determine that the object is hidden

    Does anyone know if this is correct or is it some other property I use.

    I just want on this application for one control to appear to test a condition I am doing.

    Any assistance grateful for.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How To Hide a Control With Solid Colour - What Properties?

    Welcome to the forums.

    I'm not 100 percent sure what you are asking.

    It would seem that you have the Style and Visible properties set for what you want to do. Is the actual results something other than what you expected?

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How To Hide a Control With Solid Colour - What Properties?

    I'm confused as to the whys.... but simply setting Visible = False will hide the control. No need to set the style.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    15

    Re: How To Hide a Control With Solid Colour - What Properties?

    Thanks tech, I tried that and yes it worked, the control is hidden.

    And thanks Hack for the welcome, nice to see a place where newcomers to VB are not told off for being novices as I have a few questions coming up.

    The result was expected Hack, it did hide the control and the text on the control, which was wanted, but I had seen that you had to change 2 properties on the control not just one - yet I tried just false and it did exactly what I wanted it to do - hide the whole control so when it ran it was the same colour as the form. Anyway, that worked.

  5. #5
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    Re: How To Hide a Control With Solid Colour - What Properties?

    Quote Originally Posted by michael65
    so when it ran it was the same colour as the form.
    By setting the control visible = false, it did not get the same colour as the form, it is invisible, so the form itself is shown on that place. It's just like there is no button on the form.
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    15

    Re: How To Hide a Control With Solid Colour - What Properties?

    Thanks robbed. Mike

  7. #7
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: How To Hide a Control With Solid Colour - What Properties?

    Michael, making a control invisible is sometimes a double-edged sword so be careful. For example, you cannot give an invisible or disabled control the focus without generating an error. Nor can you set an invisible option button to have a value of True.

    And, there are times when you may not want an option button to be visible and yet have a value of True. In that case I usually leave it visible and hide it behind a picture with a back color the same as the form.

    Just a thought.
    Doctor Ed

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    15

    Re: How To Hide a Control With Solid Colour - What Properties?

    Ed, it seems to be working ok that it is hidden, I do find it strange that this hidden control is wanted but I will do what the client wants, there are no pictures to hide the control behind - anyway, it seems to do what is wanted. I suppose on some applications the developer wants to see a control that the user is not meant to see - perhaps..

  9. #9
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: How To Hide a Control With Solid Colour - What Properties?

    "To make a control Invisible to the user, but still visible to the program"

    Store the Left value in the .Tag property or in a variable.
    Then to 'hide' the control, set it's left property to -999
    It will still be visible to the code, but not to the user.
    Then when you wish to make it visible to the user, you can set it's Left property back to normal.
    Rob C

  10. #10

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    15

    Re: How To Hide a Control With Solid Colour - What Properties?

    Thanks Rob - sure enough that did work too.

  11. #11
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: How To Hide a Control With Solid Colour - What Properties?

    RobC said, "Then to 'hide' the control, set it's left property to -999."
    ------------------
    That sure does beat all. Thanks a bunch. I figured that would cause some "Invalid Property" or the like, but it works.
    Doctor Ed

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