Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Create events for windows User Control.Urgent!!!

Create events for windows User Control.Urgent!!!

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RenuKhot
    wrote on last edited by
    #1

    How do we create events for a user control which is dynamically added? Thanks in advance R.K

    A 1 Reply Last reply
    0
    • R RenuKhot

      How do we create events for a user control which is dynamically added? Thanks in advance R.K

      A Offline
      A Offline
      Aslam Bari
      wrote on last edited by
      #2

      In Your control which is too added class;- Declare delegate:- public delegate void ShowTextEvent(string str,EventArgs e); Declare event:- public void ShowTextEvent MyEvent; ///////////////////////////////////////////////////////////////////// void somemethod() { //////////////////////////////// Control is added Controls.Add(NewControl); /////////////////////////////// Setting Event to this. NewControl.MyEvent+=new ShowTextEvent(OnMyEvent); } ////Handler void OnMyEvent(string str,EventArgs e) { }

      R 1 Reply Last reply
      0
      • A Aslam Bari

        In Your control which is too added class;- Declare delegate:- public delegate void ShowTextEvent(string str,EventArgs e); Declare event:- public void ShowTextEvent MyEvent; ///////////////////////////////////////////////////////////////////// void somemethod() { //////////////////////////////// Control is added Controls.Add(NewControl); /////////////////////////////// Setting Event to this. NewControl.MyEvent+=new ShowTextEvent(OnMyEvent); } ////Handler void OnMyEvent(string str,EventArgs e) { }

        R Offline
        R Offline
        RenuKhot
        wrote on last edited by
        #3

        Hi aslam, i have a user control created with a button on it. I am creating an instance of this user control using statments IComponent newComponent = Activator.CreateInstance(componentClass, objparams) as IComponent; now i need to add event to this component. i want the click event of the user control. please help. thanks in advance.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups