943,944 Members | Top Members by Rank

Ad:
Nov 7th, 2009
0

making objects invisible

Expand Post »
Hi,

Let's say I have a form full of objects and want to make all of them (or half of them, whatever) invisible. Is there a short way to do that without a need of setting visible to false individually to each object?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
deftones is offline Offline
27 posts
since Jul 2008
Nov 7th, 2009
1
Re: making objects invisible
If you are talking about design time... then,... Drag mouse over all the controls you want to make visible = false. OR, you could put these controls in a frame, picture box, or other container control.

If at runtime..., then,... Same advice. Put the controls in a picture box and set its visiblity = false.

But then there is also this way...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim C As Control
  2. For Each C In Me.Controls
  3. C.Visible = False
  4. Next C



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Nov 8th, 2009
0
Re: making objects invisible
like this
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. form1.visible = false
  2. image1.visible = false
  3. command1.visible = false
Last edited by abu taher; Nov 8th, 2009 at 1:34 am.
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Nov 8th, 2009
0
Re: making objects invisible
Click to Expand / Collapse  Quote originally posted by vb5prgrmr ...
If you are talking about design time... then,... Drag mouse over all the controls you want to make visible = false. OR, you could put these controls in a frame, picture box, or other container control.

If at runtime..., then,... Same advice. Put the controls in a picture box and set its visiblity = false.

But then there is also this way...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim C As Control
  2. For Each C In Me.Controls
  3. C.Visible = False
  4. Next C



Good Luck
I was talking about runtime, sorry didn't make that clear before.
That code you wrote works like a charm, and it would be the best solution for me, except one problem.. I've got quite a lot objects in my form and some of them doesn't have "visible" property, like Timer for instance. And I also want to leave couple of objects visible, but I guess I can't make that happen this way?
Reputation Points: 10
Solved Threads: 0
Light Poster
deftones is offline Offline
27 posts
since Jul 2008
Nov 8th, 2009
0
Re: making objects invisible
I'm sorry, spoke too quickly.. I added "on error resume next" in that cycle, and everything works fine. As concerns those other few objects which I want to leave visible..well, I can put some lines after "For...Next" in the code to set their visibility back to "true". Or maybe there is a way to exclude, let's say, a frame with all it's objects?
Last edited by deftones; Nov 8th, 2009 at 9:54 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
deftones is offline Offline
27 posts
since Jul 2008
Nov 8th, 2009
0
Re: making objects invisible
Yes it is possible by testing the C.Container.Name = "Frame1" or ...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim C As Control
  2.  
  3. For Each C In Me.Controls
  4. If C.Container.Name <> "Frame1" And C.Name <> "Frame1" Then
  5. C.Visible = False
  6. End If
  7. Next C

As for a timer control...
If C.Name <> "Timer1" Then

But then again, you could add the timer to the frame and then not need to check to see if c.name = "timer1" within the For Each loop.



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Nov 8th, 2009
0
Re: making objects invisible
That's just perfect, exactly what I was looking for. Thank you once again!
Reputation Points: 10
Solved Threads: 0
Light Poster
deftones is offline Offline
27 posts
since Jul 2008
Nov 8th, 2009
0
Re: making objects invisible
Oh, noticed one thing - this code also hides the whole menu line at the top, how do I prevent that?
Reputation Points: 10
Solved Threads: 0
Light Poster
deftones is offline Offline
27 posts
since Jul 2008
Nov 8th, 2009
0
Re: making objects invisible
Figured it out already, problem solved, don't bother
Reputation Points: 10
Solved Threads: 0
Light Poster
deftones is offline Offline
27 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: calling event form module
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Printing Array Contents to Label





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC