Event Handlers
-
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
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 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
-
just the Mouse Click event... Note that my Box.cs is a class that never inherited any object.
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
-
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
-
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.
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)