473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Bubbling properties in User Controls.....

If I create a usercontrol that is a tab with a webbrowser control on it, by
default the new control exposes no properties of the tab or webbrowser
control.

What is the easiest way to bubble the public properties, methods and
functions up to the usercontrol interface?

Nov 21 '05 #1
3 1268
For a UserControl, you can use any legal names you want for properties and
methods. For inherited controls you would use the Shadows keyword to do your
own implementation of an underlying property or method.

For a UserControl, it would look something like this:

Public Property ContainedObjectSomeProperty() As String
Get
Return Me.ContainedObject.SomeProperty
End Get
Set(ByVal Value As String)
Me.ContainedObject.SomeProperty = Value
End Set
End Property

Public Function ContainedObjectMethod(ByVal Param1 As Int32) As String
Return Me.ContainedObject.ContainedObjectMethod(Param1)
End Function

"Jim Hubbard" wrote:
If I create a usercontrol that is a tab with a webbrowser control on it, by
default the new control exposes no properties of the tab or webbrowser
control.

What is the easiest way to bubble the public properties, methods and
functions up to the usercontrol interface?

Nov 21 '05 #2
I guess what I am looking for is a way to inherit the public methods and
properties, etc. that allows me to use something like intellisense or the
drop downs to access the underlying methods, properties, etc..

Having to re-type every method, property, etc. seems like a waste of
time.....seems like I'm missing something here.

"Charlie" <cfarrier at charlesfarriersoftware.com> wrote in message
news:9B**********************************@microsof t.com...
For a UserControl, you can use any legal names you want for properties and
methods. For inherited controls you would use the Shadows keyword to do
your
own implementation of an underlying property or method.

For a UserControl, it would look something like this:

Public Property ContainedObjectSomeProperty() As String
Get
Return Me.ContainedObject.SomeProperty
End Get
Set(ByVal Value As String)
Me.ContainedObject.SomeProperty = Value
End Set
End Property

Public Function ContainedObjectMethod(ByVal Param1 As Int32) As String
Return Me.ContainedObject.ContainedObjectMethod(Param1)
End Function

"Jim Hubbard" wrote:
If I create a usercontrol that is a tab with a webbrowser control on it,
by
default the new control exposes no properties of the tab or webbrowser
control.

What is the easiest way to bubble the public properties, methods and
functions up to the usercontrol interface?

Nov 21 '05 #3
You could do a work around. It could be specific to a given UserControl, or
a more generic function that works from inside the UserControl. In the
(simpler) first case,
you could just loop through the controls of the UserControl from the hosting
form's Load event and use directcast to make form-wide references (or
whatever scope you need) of the contained controls. You would need nested
loops to get into a container control such as the TabControl.

At the more generic level, you could create a GetControls method that
operates from within the UserControl. Again, you would have to use nested
loops where you have containers. A hashtable would be a good return value
type, and you could create a naming scheme for the keys to help in
identifying the controls at the form level. Using the hashtable.containskey
you should be able to easily get a reference to the contained controls from
the form.

As an alternative, you could inherit directly from the container control,
then apply the same ideas above. At least your control would automatically
have the intellisense access you want at the top level. That would take one
layer out as you probe for the contained objects.
"Jim Hubbard" wrote:
If I create a usercontrol that is a tab with a webbrowser control on it, by
default the new control exposes no properties of the tab or webbrowser
control.

What is the easiest way to bubble the public properties, methods and
functions up to the usercontrol interface?

Nov 21 '05 #4

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

Similar topics

8
by: deko | last post by:
I'm hoping someone can sanity check my understanding of the Object Model for Forms/Controls. I'm having trouble drilling down into Control properties. First, I have a record set with the...
4
by: Andy | last post by:
Alright, I am beyond confused here and need some guidance. I need a C# only sample. I have a simple Page and within it i am creating a user control (ascx). The user control contains textboxes,...
2
by: Rubble | last post by:
Hello, Ive searched all over the net trying to find an answer to this...so anybody with some expertise in this area would be greatly appreciated. Background: I have a webform that loads a...
5
by: djscratchnsniffing | last post by:
i know you can access an ascx's properties/methods from an aspx file. Let's say you have an aspx file with two code-behind files(ascx files). Can you access one of the ascx file's...
0
by: PontiMax | last post by:
1. I've got a default user control class with an event handler 'OnBubbleEvent': public class DefaultUserControl : System.Web.UI.UserControl { public event EventHandler DoBubbling; ......
2
by: Vivek Sharma | last post by:
Hi There, I have a situation where I wish to load the controls dynamically on the basis of user role. Hence, I am using this code. if (UserRole == "IS Administrator") { Control UC1 =...
0
by: Peter Rilling | last post by:
Hi. Okay, I have read only other news postings that winforms to not support the concept of "event bubbling" that web apps do. Nevertheless, I need to implement something such that if I have a...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
0
by: Ben Crinion | last post by:
Hi Im having a bit of a problem with an exception that doesnt seem to be bubbling up from a user control to its containing user control. The exception can occur on an event fired by a user...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.