How To: Control Container

T

Tony

So, here is the (back of a cigarette packet) spec for a
new UserControl I am trying to develop -

1. It needs to be a control container

2. Scroll bars should appear if any contained control is
outside the visible area

3. A navigation button should appear if any contained
control is outside the visible area

4. Clicking the button should cause a context menu to
appear offering -
Top
Bottom
Left
Right
-
Top Left
Top Right
Bottom Left
Bottom Right

5. Clicking one of the menu options should move to the
appropriate location

6. If any contained control recieves the focus, the
container should ensure that the contained control is in
the visible region, if not then it should be automatically
scrolled into the visible region.

I have written this control in VB6 and it took me a couple
of hours. In VB.Net, I can't even get the new control to
act as a container. I have tried -

Me.SetStyle(ControlStyles.ContainerControl, True)
Me.UpdateStyles()

in the .New method but it doesn't seem to make any
difference, when a control is pasted into my new control,
it doesn't end up contained (i.e. it's parent is still the
windows form rather than my new control). I have searched
the help and various web sites for an example of a
UserControl that acts as a container (and still has a
surface that I can place the scroll bars and button on) to
no avail.

Am I missing something fundamental here? I have been
writing code for 25 years (starting out on a ZX Spectrum
and moving through GW Basic, QuickBasic versions 1 through
7 and finally all the Visual basic releases) and have
never come across anything so infuriating.

I would appreciate any help that you could offer.

Cheers, Tony Harrison

Microsoft Development Environment 2002 Version 7.0.9466
Microsoft .NET Framework 1.0 Version 1.0.3705
 
P

Pete

Hi,
So, here is the (back of a cigarette packet) spec for a
new UserControl I am trying to develop -

Can you not just inherit from UserControl to start with? I believe doing so
will give you all the benefits of the UserControl, to which you can add your
own functionality. I'm assuming that this isn't what you've done because you
say you cannot get it to act as a container?

-- Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top