User Control - User interation with controls within it.

Cheetah

Well-known member
Joined
Oct 12, 2006
Messages
232
Programming Experience
Beginner
Hi there,

I am creating a user control and i want the user to be able to move the buttons that are within the user control.

Is this possible? If so - how?

Thanks.
 
Buttons have a Location property, just like every control. If you want to move a Button you set its Location property, or perhaps its Top or Left property if you only want to move it in one direction. As to how you get the value for the new Location, that's up to you. How do you want it to work? Drag and drop? Entry of coordinates? Something else?
 
I know i can set the location, but I want to use the drag drop events of the buttons which are within the usercontrol.

So when i put that usercontrol on a form, the user can drag and drop the buttons that are on the usercontrol.

But when i put the usercontrol on the form it acts as "one entity"

Thanks.
 
So you actually meant you want developers to be able to drag and drop the child controls at design time? That's what you should have said then. You didn't mention drag and drop and you said "the user", which implies run time.
 
I mean at runtime - I want the end user to be able to drag and drop the child controls of the usercontrol at runtime.

The problem is - the usercontrol acts as one entity and therefore it drags and drops the usercontrol on the parent form.

Sorry for my crap explaination.
 
If you are finding that the UserControl is being dragged at run time as a single unit then you have obviously added logic to the form to drag the UserControl as a single unit. If you want the individual child controls within the UserControl be able to be dragged then you have to add logic to the UserControl itself to drag the child controls.
 
If you are finding that the UserControl is being dragged at run time as a single unit then you have obviously added logic to the form to drag the UserControl as a single unit. If you want the individual child controls within the UserControl be able to be dragged then you have to add logic to the UserControl itself to drag the child controls.

Sorry to bring this up again - but how can i make it drag as a single unit. Is there a property i can set or do i have to add logic to every element on the user control.

Thanks.
 
Back
Top