Drag Drop On Dynamically created controls (buttons) in FormLayOutPanels

0
0

Per this doc:   [ https://docs.wisej.com/docs/controls/general/drag-and-drop-1 ]

“Drag & drop in Wisej works exactly the same as in a desktop application”

Well I discovered that my two WiseJ flowlayoutpanels ( on a Wisej.Web.Form ) don’t believe you.

My little test project DYNAMICALLY creates buttons and adds them to a flowLayoutPanel1.Controls list

with the button property btn.AllowDrag = true;

These dynamically created buttons are to be drug to the next flowLayoutPanel    “flowLayoutPanel2”

Well the dynamically added buttons are not invoking any events even remotely related to Drag / Drop.

I’ve got messageboxes all over the place on these various events including mouse down and dblClick

on various controls just to see if any respond.  The FlowLayoutPanel ( the Source Panel #1) seems to be invoking some events

now that I set its “parent” the actual FORM itself to allow Drag but those are events on the flowLayoutPanel,  when  dragging it — ITSELF,

not the buttons inside of the panel ITSELF. ( and of course they are a hot mess, it doesn’t appear that you can access the list of Controls in this flowLayoutPanel

from the sender or event arguments

I’m hypothesizing  that since the dynamically created buttons themselves don’t even generate a click event or mouseDown event that they assuredly are not going to invoke any drag events.  UNTIL I add and associate events to these dynamic buttons    on their creation.

Please advise  ASAP   thank you

 

 

 

  • You must to post comments
0
0

I am attempting to manually add the event handler to my dynamic buttons and now this

[ https://stackoverflow.com/questions/45194678/how-can-i-manually-build-one-valid-drageventargs-object-in-order-to-call-the-win ]

  • Luca (ITG)
    That’s to fire the event. To attach the event use += like any .NET event. If there is any issue attach a test case showing what you are doing.
  • A B
    • A B
    • Jan 25, 2023 - 8:41 pm
    I attached a solution I can no longer add images or a zip apparently . the drag event handler is being strange with its first parameter as I attempt to assign it a new methos name to its default event btnDynamic.DragStart += new DragEventHandler(btnDynamic, drgEvtArgs); btnDynamic.DragStart += new DragEventHandler(btnDynamic_DraggingButton); I have a method named btnDynamic_DraggingButton or the previous attempt is the newly dynamically created button btnDynamic PLEASE ADVISE ASAP thank you
  • You must to post comments
0
0

Please attach a WinForms project that works the way you want it to work.

Best,  Alaa   

Humbly I have attached s sample solution.      Hypothesis was Drag Drop on FormLayoutPanel

I am questioning the feasibility of creating appropriate event(s) for the  dynamically created buttons

that are added to FormLayoutPanel   as THEY ,  are the controls being drug to another FormLayoutPanel.

It seemed like a pretty straightforward question to me … but   here is the test project anyway if that helps.

AGAIN for clarity per the document referenced above. which appears to operate on a row of a DataGridView.

It “SEEMS” like I will need to manually add — during the dynamic creation of my buttons their events for Drag Drop  ?

I’d like to confirm the minimum required (drag drop related ) events that I need to slap onto these dynamic buttons in my FlowLayoutPanel as

well to Drag the dynamic buttons from      FormLayoutPanel#1      to FormLayoutPanel#2

please  &   thank you

Attachment
  • Luca (ITG)
    The sample you attached doesn’t work, it doesn’t do any drag and dropping, the events are not attached, etc. If you write something that works in WinForms that shows what you want to do and that you complained it’s not working in Wisej.NET as we documented it we’ll be happy to help. To learn how to manage drag & drop events you can refer to our documentation or to MSDN.
  • A B
    • A B
    • Jan 25, 2023 - 9:13 pm
    Again thank you Luca, I do appreciate the assistance , MY ORIGINAL Inquiry ABOVE I referenced a specific Wise J document . Per this doc: [ https://docs.wisej.com/docs/controls/general/drag-and-drop-1 ] The document operates on a DataGridView’s Row. private void dataGridView1_DragStart(object sender, EventArgs e) { this.dataGridView1.DoDragDrop( this.dataGridView1.SelectedRows.ToArray(), DragDropEffects.Copy | DragDropEffects.Move); } PLEASE ALL I was REALLY asking originally was I am attempting to Drag a DYNAMICALLY created buttons from one, flowLayoutPanel, to another. My Dynamically created controls cannot be referenced with this. DynamicallyCreatedButtonNameNo1 as it is not seen in the forms designer at that point. The confusion about adding another event handler just digressed into I cant make one successfully for this event in WiseJ I tested real quick in a regular WinForms and it just accepts the method name without requiring the prefix this resulting in the error Cannot implicitly convert type ‘Wisej.Web.DragEventHandler’ to ‘System.EventHandler’ //btnDynamic.DragStart += new DragEventHandler(btnDynamic, drgEvtArgs); btnDynamic.DragStart += new DragEventHandler(this.btnDynamic_DraggingButton);
  • You must to post comments
1
0

Hi,

Please attach a WinForms project that works the way you want it to work.

Best,
Alaa

//

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.