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. Event Handlers

Event Handlers

Scheduled Pinned Locked Moved C#
csharp
6 Posts 3 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.
  • S Offline
    S Offline
    Silvyster
    wrote on last edited by
    #1

    I have created my own class names Box.cs. Now I want to borrow the mouse Event which I see in most controls found in .Net and apply it also to my box so that If I click my box an event is triggered

    OriginalGriffO S 2 Replies Last reply
    0
    • S Silvyster

      I have created my own class names Box.cs. Now I want to borrow the mouse Event which I see in most controls found in .Net and apply it also to my box so that If I click my box an event is triggered

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Which mouse event do you want to handle? There are loads: Mouse Down, Mouse up, Mouse move, ... Is your class visible (ie derived from a form, or other control? If not, then it doesn't get mouse events! More details, please!

      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • S Silvyster

        I have created my own class names Box.cs. Now I want to borrow the mouse Event which I see in most controls found in .Net and apply it also to my box so that If I click my box an event is triggered

        S Offline
        S Offline
        Silvyster
        wrote on last edited by
        #3

        just the Mouse Click event... Note that my Box.cs is a class that never inherited any object.

        OriginalGriffO 1 Reply Last reply
        0
        • S Silvyster

          just the Mouse Click event... Note that my Box.cs is a class that never inherited any object.

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          A simple class:

          class Box
          {
          ...
          }

          is not visible on screen. If it isn't visible, you can't click the mouse on it. Your class should inherit from a form, or control (panel, button, textbox, label) that can be visible. You can then add events to it. Just creating a class is not enough!

          No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          S 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            A simple class:

            class Box
            {
            ...
            }

            is not visible on screen. If it isn't visible, you can't click the mouse on it. Your class should inherit from a form, or control (panel, button, textbox, label) that can be visible. You can then add events to it. Just creating a class is not enough!

            No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

            S Offline
            S Offline
            Silvyster
            wrote on last edited by
            #5

            oh snap!... ok can you suggest me an object that i can inherit? I mean like a generic object that has it.. i dont want to extend any of the .net controls because I know that they Inherited it from some object.

            D 1 Reply Last reply
            0
            • S Silvyster

              oh snap!... ok can you suggest me an object that i can inherit? I mean like a generic object that has it.. i dont want to extend any of the .net controls because I know that they Inherited it from some object.

              D Offline
              D Offline
              DaveyM69
              wrote on last edited by
              #6

              using System.Windows.Forms;

              namespace MyNamespace
              {
              public class Box : Control
              {

              }
              

              }

              Dave
              BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
              Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
              Why are you using VB6? Do you hate yourself? (Christian Graus)

              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