I have FlowLayoutPanel and UserControl's on it with drag & drop reordering. This sort of works. But the problem is that child controls prevent dragging of the actual parent UserControl.
So my question is how to enable dragging of a UserControl that contains child controls?
If I understand you right I had the same problem as you and I solved it by propagating events of the child element to it's parent.
If you have a draggable UserControl containing a label. You have to call the events of the UserControl when the events of the label occurs. E.g. in the Label's OnMouseDown() call the UserControl's OnMouseDown() and just pass the Event-Args. I didn't find a better way than handling each event that is required for drag and drop separately.
Related
I have controls in the same place (one on top of the other)
Is there a way to get an event when the z-order changes?
The purpose is for debugging to see when and who change the order
It can be changed by BringToFront or SendToBack or SetChildIndex
Like Control.ZOrderChanged or form.Controls.ZOrderChanged
Changing the ChildIndex will trigger a Layout Event on the control that is parent to the child control. Of course this assumes that SuspendLayout has not been called on the parent control.
You can filter the event by checking the LayoutEventArgs.AffectedProperty Property (a string) to see if it is equal to "ChildIndex". To determine which control triggered the event, check the LayoutEventArgs.AffectedControl Property
I have a UserControl in my WinForms project. I add some objects of this UserControl to a FlowLayoutPanel at run time using code.
I want when I add my first UserControl to FlowLayoutPanel, change its BackColor.
Is there any event for the UserControl to aware when add it to a parent control(something like UserControlAddedToParent)?
it seems that you are looking for Control.ParentChanged event
This event is raised if the Parent property is changed by either a programmatic modification or user interaction
I have a Canvas with different Elements which are created and removed dynamically at runtime inside a canvas, which itself is in a custom Usercontrol.
Now I want to add a few Touchevents, like ManipulationStarted. However, if I bind it on the Canvas, I get the canvas back as sender in my event. I need, however, the specific UIElement that was touched, so I guess I need to bind the event directly to the children. How can I achieve this?
PS: I've already tried creating a custom Event inside the Usercontrol, which is added to the specific child when it's created, however the performance seems to suffer immensely from this approach.
I´d like to drag and drop objects in wpf solution via multitouch gesture. I get two userControls. I am able to drag an item from userControl1 and place it anywhere in my application. It sounds good so far, but here is the problem:
If I move userControl1, the dragged and placed item is going to move with userControl1. That means even though I moved an item before out of userControl1, it is still connected to that userControl.
I would like to drag an item from userControl1 and place it in userControl2. There shouldn´t be any data binding between the item and userControl1 anymore, when I drag the item out of the userControl.
Does anybody know a suitable answer for my problem?
Check out the SurfaceDragDrop class in the "Surface Toolkit for Windows Touch"
I have a windows form that contains two usercontrols. One usercontrol contains two list views. The other usercontrol has a grid.
Within the first usercontrol the two list views drag and drop their contents between each other.
The grid usercontrol is setup to dragdrop onto the listview usercontrol.
The problem is that the drag drop event within the listview usercontrol always takes precedence over the dragdrop between the two usercontrols.
So if I drag from the grid usercontrol over the listview usercontrol it will execute the internal dragdrop event of the listview control.
In other words it fires this event
lv_groupActivites_DragDrop
instead of
reservationScheduleBooking1_DragDrop
Is there anyway of specifying which drag drop event should be fired?
You are dragging from the grid in one user control and trying to drop onto a specific listview on the other user control or anywhere on the other user control?
If you want to drop anywhere on the other user control, I think you will need to setup the apprporate event handler on that user control to respond. If you want to drop on to a specific listview that also accepts drag events from the other listview you will need to do extra work in your event handler on that listview to figure out where the drag initiated from.