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.
Re: How To Hide a Control With Solid Colour - What Properties?
Welcome to the forums. :wave:
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?
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
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.
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.
Re: How To Hide a Control With Solid Colour - What Properties?
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.
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..
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.
Re: How To Hide a Control With Solid Colour - What Properties?
Thanks Rob - sure enough that did work too.
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.