|
-
Nov 13th, 2002, 03:55 PM
#1
Thread Starter
yay gay
inheriting picturebox's events
i want to inherit a class from PictureBox control and that when the event mouseEnter and mouseHover happens it makes something...how do i do that?
pay attention that i dont want to make that the user that uses the class has to write that code..what im questioning is how i make that the class implements that so the user has to write none in the final code
-
Nov 13th, 2002, 05:17 PM
#2
Frenzied Member
you cant. If you inherit a class, you have to write your own code if you want to change anything. So if you inherit from the picturebox class and want to change the implementation of the mouseEnter and mouseHover, you have to override them.
Dont gain the world and lose your soul
-
Nov 13th, 2002, 05:19 PM
#3
Thread Starter
yay gay
yea i know but how do i make that?
-
Nov 13th, 2002, 05:24 PM
#4
Frenzied Member
PHP Code:
protected override OnMouseEnter(MouseEventArgs e)
{
//code here
}
When I get home I try to see if I can do an example.
Dont gain the world and lose your soul
-
Nov 13th, 2002, 05:24 PM
#5
Thread Starter
yay gay
ah is it that easy? i though i'd have to make delegates and blablabla lolol
-
Nov 13th, 2002, 05:32 PM
#6
Thread Starter
yay gay
didnt work..it overrided as function:
PHP Code:
public override void MouseHover(object sender, System.EventArgs e)
{
MessageBox.Show("...");
}
-
Nov 13th, 2002, 05:34 PM
#7
Thread Starter
yay gay
ah putting the OnMouseHover worked like a sharm
-
Nov 13th, 2002, 05:37 PM
#8
Thread Starter
yay gay
C:\Documents and Settings\JBRANCO\My Documents\Visual Studio Projects\WindowsApplication10\Form1.cs(174): 'WindowsApplication10.extraPictureBox.OnMouseHover(object, System.EventArgs)': no suitable method found to override
bah!
-
Nov 13th, 2002, 05:42 PM
#9
Thread Starter
yay gay
did it 
i had to take away the sender object
-
Nov 13th, 2002, 05:46 PM
#10
Thread Starter
yay gay
-
Nov 13th, 2002, 08:19 PM
#11
Frenzied Member
The reason for the 1 sec wait is because of the hover. If you over override the OnMouseEnter, its much faster.
and it only raises the event on the class..if i try to use the class' event it just won't execute
What do you mean by this?
Dont gain the world and lose your soul
-
Nov 14th, 2002, 03:57 AM
#12
Thread Starter
yay gay
i mean it raises the override i made...but when make
myClass class = new myClass();
class.MouseHover += new blablabla
private void class_MouseHover(blablabla)
code
this part won't be executed..!
-
Nov 14th, 2002, 10:59 AM
#13
Frenzied Member
Post the code and I'll take a look at it.
Dont gain the world and lose your soul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|