PC Review


Reply
Thread Tools Rate Thread

can't seem to hide user control with code

 
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      16th May 2005
Hi I am trying to conditionally hide a user control on a form in the code.
There is a visible element in the properties box of the user control but in
the .vb file (in the code) the object does not seem available. Using me. the
intellsince does not show the user control name, so can not seem to get to
its properties in code.
Thanks.
Paul G
Software engineer.
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      16th May 2005
So this is a user control you've created?
If so, you probably need to implement your own version of the visible
property and put code similar to this in it:

For each ctrl as Control in Me.Controls
ctrl.Visible=Value
Next

Here's more info:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Paul" <(E-Mail Removed)> wrote in message
news:4BAA779C-5CF0-4795-A90C-(E-Mail Removed)...
> Hi I am trying to conditionally hide a user control on a form in the code.
> There is a visible element in the properties box of the user control but
> in
> the .vb file (in the code) the object does not seem available. Using me.
> the
> intellsince does not show the user control name, so can not seem to get to
> its properties in code.
> Thanks.
> Paul G
> Software engineer.



 
Reply With Quote
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      16th May 2005
Hi thanks for the response. It is a control that I created.
I tried the following but get a runtime error (Object reference is not set
to an instance of an object) when using
Imports projectname.usercontrolname '
Me.usercontrolname.Visible = False ' runtime error occures here.
I also set up the code below like what you had suggested which seems to run
ok but not sure if it is itterating through all of the controls on the form.
For Each ctrl As Control In Me.Controls
ctrl.Visible = True
Next



"Steve C. Orr [MVP, MCSD]" wrote:

> So this is a user control you've created?
> If so, you probably need to implement your own version of the visible
> property and put code similar to this in it:
>
> For each ctrl as Control in Me.Controls
> ctrl.Visible=Value
> Next
>
> Here's more info:
> http://SteveOrr.net/faq/ControlTreeRecursion.aspx
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
> "Paul" <(E-Mail Removed)> wrote in message
> news:4BAA779C-5CF0-4795-A90C-(E-Mail Removed)...
> > Hi I am trying to conditionally hide a user control on a form in the code.
> > There is a visible element in the properties box of the user control but
> > in
> > the .vb file (in the code) the object does not seem available. Using me.
> > the
> > intellsince does not show the user control name, so can not seem to get to
> > its properties in code.
> > Thanks.
> > Paul G
> > Software engineer.

>
>
>

 
Reply With Quote
 
sam
Guest
Posts: n/a
 
      16th May 2005
I think asp.net for efficiency reasons creates 5 child controls, some
of which are null. So you need to insert into the foreach loop:
if(ctrl != null) { ctrl.Visible = True }

or however you write that in VB.

 
Reply With Quote
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      16th May 2005
ok thanks for the information, think it would be
if ctrl <> NULL then
ctrl.visible = True
end if

"sam" wrote:

> I think asp.net for efficiency reasons creates 5 child controls, some
> of which are null. So you need to insert into the foreach loop:
> if(ctrl != null) { ctrl.Visible = True }
>
> or however you write that in VB.
>
>

 
Reply With Quote
 
Tarren
Guest
Posts: n/a
 
      19th May 2005
just put an aspanel around the user control and hide that when needed.

"Paul" <(E-Mail Removed)> wrote in message
news:4BAA779C-5CF0-4795-A90C-(E-Mail Removed)...
> Hi I am trying to conditionally hide a user control on a form in the code.
> There is a visible element in the properties box of the user control but
> in
> the .vb file (in the code) the object does not seem available. Using me.
> the
> intellsince does not show the user control name, so can not seem to get to
> its properties in code.
> Thanks.
> Paul G
> Software engineer.



 
Reply With Quote
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      19th May 2005
Sounds like a good idea. Thanks.
--
Paul G
Software engineer.


"Tarren" wrote:

> just put an aspanel around the user control and hide that when needed.
>
> "Paul" <(E-Mail Removed)> wrote in message
> news:4BAA779C-5CF0-4795-A90C-(E-Mail Removed)...
> > Hi I am trying to conditionally hide a user control on a form in the code.
> > There is a visible element in the properties box of the user control but
> > in
> > the .vb file (in the code) the object does not seem available. Using me.
> > the
> > intellsince does not show the user control name, so can not seem to get to
> > its properties in code.
> > Thanks.
> > Paul G
> > Software engineer.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide user control kmercer46@yahoo.com Microsoft ASP .NET 1 7th Jun 2006 02:58 PM
hide user control Microsoft VB .NET 1 13th Feb 2006 06:51 AM
Trying to hide a user control Geoff Pennington Microsoft Dot NET 2 28th Jul 2005 03:53 PM
Re: Hide code from user losmac Microsoft Excel Programming 0 19th Aug 2003 08:12 PM
Re: Hide code from user Ron de Bruin Microsoft Excel Programming 0 19th Aug 2003 04:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 AM.