How to add an event for dynamically generated label in c# windows application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kpreddy
    New Member
    • Mar 2008
    • 1

    How to add an event for dynamically generated label in c# windows application

    hello friends,

    I am creating a win form where i need to drag and drop a label from panel 1 to panel 2 . as soon as i drop the label in panel 2, label from panel 1 must deleted. and again if i drag and drop the label from panel 2 to panel 1 it should be deleted from panel 2 and must display in panel 1.

    and also how to write DragDrop event for dynamically generated label.

    please give me some idea how to implement if possible examples.

    thanks in advance.
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    I dont think you should be deleting and creating new labels, rather play with the same label.

    Create the drag and drop events and send the label as areference in the drag data.

    Once it is dropped into a panel, remove the control from the other panel and add it to the panel it was dropped onto.

    If you still want to create a dynamic label, then create a method that will be called by the drag event of your dynamically generated label, and assign that method to the label, everytime you create it

    Comment

    Working...