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. UserControl _Click Event

UserControl _Click Event

Scheduled Pinned Locked Moved C#
helpquestion
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
    Radgar
    wrote on last edited by
    #1

    Hi all, I've created a UserControl having a picturebox control on it. Then I added my UserControl to the Windows Form and also added the _Click event. My problem is; when I click the UserControl the event is fired just fine but when I click the picturebox on the UserControl - nothing happens. What would you suggest? :doh: Thanks Radgar

    S 1 Reply Last reply
    0
    • R Radgar

      Hi all, I've created a UserControl having a picturebox control on it. Then I added my UserControl to the Windows Form and also added the _Click event. My problem is; when I click the UserControl the event is fired just fine but when I click the picturebox on the UserControl - nothing happens. What would you suggest? :doh: Thanks Radgar

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Add an event handler to your UserControl that catches the Click event of the contained PictureBox and raises the Click event of your UserControl.

      YourUserControl : UserControl
      {
      private PictureBox pictureBox1;
      ...
      this.pictureBox1.Click += new EventHandler(pictureBox1_Click);
      ...
      private void pictureBox1_Click(object sender, EventArgs e)
      {
      this.OnClick(e);
      }
      }


      www.troschuetz.de

      R 1 Reply Last reply
      0
      • S Stefan Troschuetz

        Add an event handler to your UserControl that catches the Click event of the contained PictureBox and raises the Click event of your UserControl.

        YourUserControl : UserControl
        {
        private PictureBox pictureBox1;
        ...
        this.pictureBox1.Click += new EventHandler(pictureBox1_Click);
        ...
        private void pictureBox1_Click(object sender, EventArgs e)
        {
        this.OnClick(e);
        }
        }


        www.troschuetz.de

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

        Thank you Stefan but I did it yesterday by adding a public delegate & event handler. Your way is much easier. Thanx! Radgar "Imagination is more important than knowledge." - Albert Einstein

        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