473,881 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl: Hide Children

Hi,

I have a UserControl with some "Children" (e.g. one ComboBox & one Label).

I add the UserControl on a Form.
If I perform a recursive scan through that Form's Control-Collection the ..HasChildren-Method scans the Controls within the UserControl.

This is a behavior I want to ommit.

* Is there a way to hide the Controls contained within a UserControl so that UserControl.Has Children will always return False? *

TIA,

Michael
Nov 20 '05 #1
4 1710
Hi,

I can't think of a way to override the behavior of this property,
do you mean you want to recursive scan from the From but want to skip step
into on certain UserControl type?

Maybe you could add a user-defined attribute on the definiation of the
usercontrol and check the value of this attribute in your recursive
algorithm.

another approach maybe derive from the UserControl class and define an
abstract method on to enumerate it's children,
then derive your user control from this class and implement the enumeration
in each classes, so that we could divide the recursive scan into one method
call, and every class will execute based on it's defined behavior.

Feel free to reply this thread if you have anything unclear about it.

Have a nice day!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.

Nov 20 '05 #2
Hi Yin-Shen,

Thanks for your reply.
It's a pitty the Framework hasn't got a "standard" method to achieve this....

Anyway: thanks for your directives. It is indeed quite simple to achieve with a Custom Attribute.
Here's how I handled it:

<DebuggerStepTh rough(), AttributeUsage( AttributeTarget s.Class)> _
Public Class SkipRecursiveSc anOnChildren
Inherits Attribute
End Class

***************
<SkipRecursiveS canOnChildren() > _
Public Class UIButtonComboBo x
Inherits System.Windows. Forms.UserContr ol
............... .
***************
If [Control].HasChildren And Not SkipChildren([Control]) Then
......
End If

Private Function SkipChildren(By Val [Control] As System.Windows. Forms.Control) As Boolean
Dim att() As Object = _
[Control].GetType.GetCus tomAttributes(G etType(SkipRecu rsiveScanOnChil dren), True)
Return (UBound(att) > -1)
End Function

Best regards,

Michael
""Ying-Shen Yu[MSFT]"" <v-***@online.micr osoft.com> wrote in message news:fS******** *****@cpmsftngx a10.phx.gbl...
Hi,

I can't think of a way to override the behavior of this property,
do you mean you want to recursive scan from the From but want to skip step
into on certain UserControl type?

Maybe you could add a user-defined attribute on the definiation of the
usercontrol and check the value of this attribute in your recursive
algorithm.

another approach maybe derive from the UserControl class and define an
abstract method on to enumerate it's children,
then derive your user control from this class and implement the enumeration
in each classes, so that we could divide the recursive scan into one method
call, and every class will execute based on it's defined behavior.

Feel free to reply this thread if you have anything unclear about it.

Have a nice day!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.

Nov 20 '05 #3
Sorry about the long delay, I just saw your post.

What I do is, while iterating through the hierarchy, when I am looking at a
control, say

if typename(someco ntrol.parent ) = "UserContro l" then
'do something, ignore it, whatever
Else
'do something else
Endif
"Michael Maes" <mi*****@merlot .com> wrote in message
news:OD******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

I have a UserControl with some "Children" (e.g. one ComboBox & one Label).

I add the UserControl on a Form.
If I perform a recursive scan through that Form's Control-Collection the
..HasChildren-Method scans the Controls within the UserControl.

This is a behavior I want to ommit.

* Is there a way to hide the Controls contained within a UserControl so that
UserControl.Has Children will always return False? *

TIA,

Michael
Nov 21 '05 #4
Hi Selden,

Thanks for your input. It's another solution too.

Michael

"Selden McCabe" <sm*****@integr antInc.com> wrote in message
news:e9******** *****@tk2msftng p13.phx.gbl...
Sorry about the long delay, I just saw your post.

What I do is, while iterating through the hierarchy, when I am looking at a control, say

if typename(someco ntrol.parent ) = "UserContro l" then
'do something, ignore it, whatever
Else
'do something else
Endif
"Michael Maes" <mi*****@merlot .com> wrote in message
news:OD******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

I have a UserControl with some "Children" (e.g. one ComboBox & one Label).

I add the UserControl on a Form.
If I perform a recursive scan through that Form's Control-Collection the
.HasChildren-Method scans the Controls within the UserControl.

This is a behavior I want to ommit.

* Is there a way to hide the Controls contained within a UserControl so that UserControl.Has Children will always return False? *

TIA,

Michael

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12197
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow { display: none; }
2
3825
by: Øyvind Isaksen | last post by:
Is it possible to show/hide a usercontrol code behind? <uc1:topart id="Topart1" runat="server"></uc1:topart> This is what i want to do, but this does not work: if objDR.read me.Topart1.show 'Show usercontrol if datareader.read else me.Topart1.hide 'Hide usercontrol
3
3048
by: Jeff | last post by:
Hey ASP.NET 2.0 This the ObjectDataSource in my UserControl, <asp:ObjectDataSource ID="odsMessage" runat="server" SelectMethod="ExecuteMessage" TypeName="AH.MyNetwork.BLL.Network.Message"> <SelectParameters> <asp:ProfileParameter Name="user" PropertyName="UserName"
10
2438
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from the codebehind of the UserControl? For instance, suppose that the UserControl is dropped inside one...
2
2387
by: ruca | last post by:
Hi, Can anyone tell me please how can I return values from a popup to a UserControl. I use the same "method" like to return to a WebForm, but it not works in UserControl case. I have this code to return from popup to webform: ------------------------------------------------------------------------ sbScript.Append("<script language='javascript'>")
4
1832
by: xkeops | last post by:
I'm working in VS2003 VB.NET environment. I created a based class template (BasePage) and there is a new aspx win form (winform1.aspx) inheriting BasePage. In winform1.aspx I have added a new usercontrol uc1 and in uc1 I have a textbox and a save button (btn_Save). When I click the save button the btnSave_Click event doesn't fire.
1
18840
by: =?Utf-8?B?S3lsZSBNLiBCdXJucw==?= | last post by:
I have a set of controls and logic that must be invoked from several pages within a web application as a popup dialog, so I intend to use a userControl contained in a panel extended with the modalPopupExtender to get this behavior. I want to deal with showing and hiding the popup in server-side code, so I've set the TargetControlID to a hidden (style=display:none;) button and not set the OkButton or CancelButton. The userControl has...
6
5364
by: sundarvenkata | last post by:
Hi All, I have a custom UserControl that is used as the list item in a listbox in my main WPF window. Is it possible to have key bindings that apply to every instance of the user control? For example, I have a keybinding Alt+R for a button in the UserControl. However when there are multiple instances of the UserControl in the listbox in my main WPF window, pressing Alt+R just shifts the keyboard focus to the button in the first user...
1
5424
by: Bill McCormick | last post by:
I have a TreeView that I want to populate with pre-built items through code. Running the code (see Ref Code below) throws a XamlParseException: Cannot create instance of 'Window1' defined in assembly 'WpfApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9. This sort of works, except the top level item is...
0
11095
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10812
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10399
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9552
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7108
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.