making objects invisible

Thread Solved

Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster

making objects invisible

 
0
  #1
16 Days Ago
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 799
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 146
vb5prgrmr vb5prgrmr is offline Offline
Master Poster
 
1
  #2
15 Days Ago
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
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 467
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 23
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training
 
0
  #3
15 Days Ago
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; 15 Days Ago at 1:34 am.
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #4
15 Days Ago
Originally Posted by vb5prgrmr View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #5
15 Days Ago
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; 15 Days Ago at 9:54 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 799
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 146
vb5prgrmr vb5prgrmr is offline Offline
Master Poster
 
0
  #6
15 Days Ago
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
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #7
15 Days Ago
That's just perfect, exactly what I was looking for. Thank you once again!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #8
15 Days Ago
Oh, noticed one thing - this code also hides the whole menu line at the top, how do I prevent that?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #9
15 Days Ago
Figured it out already, problem solved, don't bother
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC