鼠标事件-图片上的MouseEnter事件. [英] Mouse Events -- MouseEnter event on a picture.
问题描述
我需要一个执行以下操作的代码项目:
我有一个循环,可在加载窗口时在屏幕上添加图片.
目的是玩纸牌游戏,当我(玩家)用光标输入其中一张纸牌时,我正在尝试这样做-该纸牌略微向上移动,
我知道这与鼠标事件有关,MOUSEENTER之类的东西
但是我没有设法使它在添加的图片上起作用.
真正的问题是我无法命名这些图片,因为它像60-70张图片一样,我认为答案不是制作70个PICTUREBOX,而每个人都在制作MOUSE EVENT FUNCTION
请帮忙!!!!
非常感谢♥
I need a codeproject that does the following:
I have a loop that adds pictures to the screen while loading the window.
The purpose is a card game, and I am trying to do that when me (the player) enters one of his cards with the cursor - the card goes a little up,
I know that it is something with the mouse events, MOUSEENTER something like that
But I didn''t manage to make it work on the pictures I add.
The real problem is that I can''t name those pictures because it''s like 60-70 pictures and I don''t think the answer is making 70 PICTUREBOXes and on everyone of them making a MOUSE EVENT FUNCTION
Please help!!!!
Thanx a lot ♥
推荐答案
将图片添加到表单时,为其注册一个MouseEnter
事件.此时,您可以确定导致事件的图片.
As you add the pictures to the form, register a MouseEnter
event for it. At that point, you can determine which picture caused the event.
void p_MouseEnter(object sender, EventArgs e)
{
PictureBox p = (PictureBox)sender;
p.SetBounds(p.Bounds.X, 650, 75, 120);
Controls.Add(this.p);
}
void p_MouseLeave(object sender, EventArgs e)
{
PictureBox p = (PictureBox)sender;
p.SetBounds(p.Bounds.X, 680, 75, 120);
Controls.Add(p);
}
感谢您的帮助!!!!!!!!!!!!!!!!!! ♥♥♥
THANK YOU FOR YOUR HELP!!!!!!!!!!!!!!!!!! ♥ ♥ ♥
void pt_MouseEnter(object sender, EventArgs e)
{
PictureBox pt = (PictureBox)sender;
pt.SetBounds(pt.Bounds.X, 520, 70, 100);
Controls.Add(this.pt);
}
void pt_MouseLeave(object sender, EventArgs e)
{
PictureBox pt = (PictureBox)sender;
pt.SetBounds(pt.Bounds.X, 550, 75, 100);
Controls.Add(pt);
}
这篇关于鼠标事件-图片上的MouseEnter事件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!