How to create a user control container?

J

Joseph Geretz

Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the richness
and elegance of the environment. However, richness and elegance should be
dedicated toward making development easier for developers, not more
difficult. In many ways this goal is achieved. However, I've run up against
one particular area of development, where what should be a trivial excercise
is turning out to be much more difficult than it should be. I'm trying to
devleop a user control which will act as the container for other controls.

Why do I think this should be easy? Well, it used to be very easy. In VB6
all we'd need to do is set the UserControl's ControlContainer property to
True. Done.

In .NET it doesn't seem that it should be any more difficult. The following
creates a user control onto which I can drop other controls when I'm working
with this control in another project.

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class SRSPanel : UserControl
{

OK, that works as far as it goes, however, at run time I'm experiencing a
problem which is an absolute show-stopper to my implementation. When focus
is on the last control contained within my control, and the Tab key is
pressed, focus does not move to the next control in the tab order on the
current form. Rather, a beep is issued and the cursor remains where it is.

1. Why does this happen?
2. How do I handle this?

Has anyone created a control container in .NET? Have you seen this problem?
How do you handle this?

Thanks very much for your help!

- Joseph Geretz -
 
N

Nicholas Paldino [.NET/C# MVP]

Joseph,

You are going to have to provide a complete code sample which shows what
you are experiencing. What you have given isn't nearly enough information
to go on.
 
J

Joseph Geretz

Thanks Nicholas for putting me on the right track.

Although I've built other user controls, this one is the first container I'm
building. When I came across this behavior, I thought that this is endemic
to the container aspect of the control. You asked me to put together a code
sample and I thought, OK easy enough. I put together a simple container
control and lo and behold - it works perfectly.

Right now, I'm in the process of tearing down the complexity of my container
control. When I find out what has been causing the problem I will post back
to the group.

(In the meantime, may I remove foot from mouth? ;-)

Thanks!

- Joseph Geretz -

Nicholas Paldino said:
Joseph,

You are going to have to provide a complete code sample which shows
what you are experiencing. What you have given isn't nearly enough
information to go on.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Joseph Geretz said:
Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the
richness and elegance of the environment. However, richness and elegance
should be dedicated toward making development easier for developers, not
more difficult. In many ways this goal is achieved. However, I've run up
against one particular area of development, where what should be a
trivial excercise is turning out to be much more difficult than it should
be. I'm trying to devleop a user control which will act as the container
for other controls.

Why do I think this should be easy? Well, it used to be very easy. In VB6
all we'd need to do is set the UserControl's ControlContainer property to
True. Done.

In .NET it doesn't seem that it should be any more difficult. The
following creates a user control onto which I can drop other controls
when I'm working with this control in another project.

[Designer("System.Windows.Forms.Design.ParentControlDesigner,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
public partial class SRSPanel : UserControl
{

OK, that works as far as it goes, however, at run time I'm experiencing a
problem which is an absolute show-stopper to my implementation. When
focus is on the last control contained within my control, and the Tab key
is pressed, focus does not move to the next control in the tab order on
the current form. Rather, a beep is issued and the cursor remains where
it is.

1. Why does this happen?
2. How do I handle this?

Has anyone created a control container in .NET? Have you seen this
problem? How do you handle this?

Thanks very much for your help!

- Joseph Geretz -
 
J

Joseph Geretz

Strange. I tore out all functionality and re-added the code step by step.
Tabbing works just fine. I have no idea what the problem was.

Thanks for pointing me in the right direction.

Joseph Geretz

Joseph Geretz said:
Thanks Nicholas for putting me on the right track.

Although I've built other user controls, this one is the first container
I'm building. When I came across this behavior, I thought that this is
endemic to the container aspect of the control. You asked me to put
together a code sample and I thought, OK easy enough. I put together a
simple container control and lo and behold - it works perfectly.

Right now, I'm in the process of tearing down the complexity of my
container control. When I find out what has been causing the problem I
will post back to the group.

(In the meantime, may I remove foot from mouth? ;-)

Thanks!

- Joseph Geretz -

Nicholas Paldino said:
Joseph,

You are going to have to provide a complete code sample which shows
what you are experiencing. What you have given isn't nearly enough
information to go on.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Joseph Geretz said:
Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the
richness and elegance of the environment. However, richness and elegance
should be dedicated toward making development easier for developers, not
more difficult. In many ways this goal is achieved. However, I've run up
against one particular area of development, where what should be a
trivial excercise is turning out to be much more difficult than it
should be. I'm trying to devleop a user control which will act as the
container for other controls.

Why do I think this should be easy? Well, it used to be very easy. In
VB6 all we'd need to do is set the UserControl's ControlContainer
property to True. Done.

In .NET it doesn't seem that it should be any more difficult. The
following creates a user control onto which I can drop other controls
when I'm working with this control in another project.

[Designer("System.Windows.Forms.Design.ParentControlDesigner,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
public partial class SRSPanel : UserControl
{

OK, that works as far as it goes, however, at run time I'm experiencing
a problem which is an absolute show-stopper to my implementation. When
focus is on the last control contained within my control, and the Tab
key is pressed, focus does not move to the next control in the tab order
on the current form. Rather, a beep is issued and the cursor remains
where it is.

1. Why does this happen?
2. How do I handle this?

Has anyone created a control container in .NET? Have you seen this
problem? How do you handle this?

Thanks very much for your help!

- Joseph Geretz -
 
N

Nicholas Paldino [.NET/C# MVP]

Ha! You did all the work, I didn't do anything. I'm glad you fixed the
problem though.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Joseph Geretz said:
Strange. I tore out all functionality and re-added the code step by step.
Tabbing works just fine. I have no idea what the problem was.

Thanks for pointing me in the right direction.

Joseph Geretz

Joseph Geretz said:
Thanks Nicholas for putting me on the right track.

Although I've built other user controls, this one is the first container
I'm building. When I came across this behavior, I thought that this is
endemic to the container aspect of the control. You asked me to put
together a code sample and I thought, OK easy enough. I put together a
simple container control and lo and behold - it works perfectly.

Right now, I'm in the process of tearing down the complexity of my
container control. When I find out what has been causing the problem I
will post back to the group.

(In the meantime, may I remove foot from mouth? ;-)

Thanks!

- Joseph Geretz -

Nicholas Paldino said:
Joseph,

You are going to have to provide a complete code sample which shows
what you are experiencing. What you have given isn't nearly enough
information to go on.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the
richness and elegance of the environment. However, richness and
elegance should be dedicated toward making development easier for
developers, not more difficult. In many ways this goal is achieved.
However, I've run up against one particular area of development, where
what should be a trivial excercise is turning out to be much more
difficult than it should be. I'm trying to devleop a user control which
will act as the container for other controls.

Why do I think this should be easy? Well, it used to be very easy. In
VB6 all we'd need to do is set the UserControl's ControlContainer
property to True. Done.

In .NET it doesn't seem that it should be any more difficult. The
following creates a user control onto which I can drop other controls
when I'm working with this control in another project.

[Designer("System.Windows.Forms.Design.ParentControlDesigner,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
public partial class SRSPanel : UserControl
{

OK, that works as far as it goes, however, at run time I'm experiencing
a problem which is an absolute show-stopper to my implementation. When
focus is on the last control contained within my control, and the Tab
key is pressed, focus does not move to the next control in the tab
order on the current form. Rather, a beep is issued and the cursor
remains where it is.

1. Why does this happen?
2. How do I handle this?

Has anyone created a control container in .NET? Have you seen this
problem? How do you handle this?

Thanks very much for your help!

- Joseph Geretz -
 
K

kris

Hi Joseph,

Can you please send me the code for your sample application?
I am also in the process of developing a control that can act as a container
for my controls , images ,text , documents.
your code would be of great help to me.

Thanks you

Regards
Kris
 

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