Can't move nested control in custom container control

R

Robert C. Nell

I've created a user control that acts like a container control. I can add
controls to it but after they are added they cannot be moved with the mouse
or arrow keys. Additionally, when the nested control is selected the focus
rectangle does not appear around it. The control does have focus though
because the properties for it are shown. The Location property of the
nested control can be manipulated to move the control but that is an
unacceptable method to move the control.

What do I need to add to enable mouse/keyboard movement of the nested
control?
 
T

Tom Clement

Hi Robert.

I've made a lot of container user controls and haven't noticed this problem.
I guess you already know to attribute the UserControl class something like
this:

[Designer("System.Windows.Forms.Design.ParentControlDesigner,
System.Design", typeof(IDesigner))]
public class MyPanel : System.Windows.Forms.UserControl

If not, that's probably the problem. If so, sorry I can't help.

Tom
 
R

Robert C. Nell

Thanks for the response Tom. I did attribute the class in the same manner
you noted.

I found that my issue was due to me not calling the base OnControlAdded
method. I have it overridden so I can position the added control in a
certain area of the user control.



Tom Clement said:
Hi Robert.

I've made a lot of container user controls and haven't noticed this problem.
I guess you already know to attribute the UserControl class something like
this:

[Designer("System.Windows.Forms.Design.ParentControlDesigner,
System.Design", typeof(IDesigner))]
public class MyPanel : System.Windows.Forms.UserControl

If not, that's probably the problem. If so, sorry I can't help.

Tom

Robert C. Nell said:
I've created a user control that acts like a container control. I can add
controls to it but after they are added they cannot be moved with the mouse
or arrow keys. Additionally, when the nested control is selected the focus
rectangle does not appear around it. The control does have focus though
because the properties for it are shown. The Location property of the
nested control can be manipulated to move the control but that is an
unacceptable method to move the control.

What do I need to add to enable mouse/keyboard movement of the nested
control?
 

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