Exposing my controls 
Author Message
 Exposing my controls

Hi,
I have written a control, let's call it Bob.ctl. I want to write another
control that contains Bob.ctl. I assmume the way to do this is to use Set
and Get procedures that pass references to and from the contained Bob.

E.g.

Public Property Set Bob(ByVal newBob As TTCommonControls.Bob)
Set MyControl.Bob = newBob
End Property

Public Property Get Bob() As TTCommonControls.Bob
Set Bob= MyControl.Bob
End Property

Then in my client application I can enter NewControl.Bob.SomeMethod.

Unfortunately the compiler won't let me do this. The only way I can do it is
if pass and receive Bob as an Object data type. This means that I do not
have the drop down list of Bob's methods and Properties when I type
NewControl.Bob.

Is there a way around this or am I resigned to passing Bob as an object data
type?

Any help much appreciated.

Thanks,.
Jonathan



Sun, 07 Jul 2002 03:00:00 GMT  
 Exposing my controls
Well, I must admit that I really don't understand what you are trying to
accomplish, but here are the basic ways that you add a control to another
control:

1. Drop your child control onto the UserControl surface of the parent control in
design time.
2. Use the Controls.Add method of the parent control to load an instance of your
child control dynamically at run time.

The first is obviously an easier solution, but the second one is extremely
powerful.  Loading controls dynamically offers may not be what you want, though,
so I would recommend that you start off by seeing if the first one will suit
your needs.  If what you need is to load controls dynamically, I can offer a lot
of good reading material that will lead you safely down that path.

HTH,
ian

Quote:

> Hi,
> I have written a control, let's call it Bob.ctl. I want to write another
> control that contains Bob.ctl. I assmume the way to do this is to use Set
> and Get procedures that pass references to and from the contained Bob.

> E.g.

> Public Property Set Bob(ByVal newBob As TTCommonControls.Bob)
> Set MyControl.Bob = newBob
> End Property

> Public Property Get Bob() As TTCommonControls.Bob
> Set Bob= MyControl.Bob
> End Property

> Then in my client application I can enter NewControl.Bob.SomeMethod.

> Unfortunately the compiler won't let me do this. The only way I can do it is
> if pass and receive Bob as an Object data type. This means that I do not
> have the drop down list of Bob's methods and Properties when I type
> NewControl.Bob.

> Is there a way around this or am I resigned to passing Bob as an object data
> type?

> Any help much appreciated.

> Thanks,.
> Jonathan



Sun, 07 Jul 2002 03:00:00 GMT  
 Exposing my controls
Jonathan,

Quote:
> I have written a control, let's call it Bob.ctl. I want to write another
> control that contains Bob.ctl. I assume the way to do this is to use Set
> and Get procedures that pass references to and from the contained Bob.

Generally you would not want to set the control from outside the NewControl
if it is _contained_ in NewControl as opposed to being  _referenced_ by
NewControl.

Quote:
> Unfortunately the compiler won't let me do this. The only way I can do it
is
> if pass and receive Bob as an Object data type. This means that I do not
> have the drop down list of Bob's methods and Properties when I type
> NewControl.Bob.

I like Intellisense also. But, the real reason, IMO, you want to avoid
object references is so that the compiler does as much work catching typos
as possible. In either case, the solution is to accept the parameter as an
Object, and immediately assign it to a correctly dimmed variable. In your
case, you are already doing this because MyControl.Bob is probably dimmed as
CBob. It is the parameter declaration that needs to be object.

HTH.

--
Kathleen
(MS-MVP)
Reply in the newsgroup so everyone can benefit
--



Mon, 08 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ActiveX - How do I expose a Control Array to the Control Author

2. HELP! SelectedIndexChanged not exposed on control

3. URGENT : Support for exposing .NET controls to COM

4. UserControl Exposing Another Control In Properties???

5. Exposing and controlling reports in .mdb's

6. Exposing user control click event

7. Exposing my controls

8. Exposing User Control Properties w/in DataRepeater

9. Expose child controls' members in UserControl?

10. Exposing public functions without exposing everything

11. Expose array properties of a constituent control to the ActiveX control

12. Exposing methods from .NET user control

 

 
Powered by phpBB® Forum Software