Tablelayoutpanel - 鼠标悬停效果 [英] Tablelayoutpanel – mouse over effect

查看:112
本文介绍了Tablelayoutpanel - 鼠标悬停效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格上有一个TableLayoutPanel(5列/ 2行)图片显示在第1行,每张图片的描述显示在第2行。有没有办法改变与其图片相关的文字的颜色(第2行)当用户将鼠标移到图片上时(第1行)?



我尝试过的事情:



我还没有尝试过任何东西,我不知道从哪里开始。

I have a TableLayoutPanel on a form (5 columns / 2 rows) Pictures are presented in row 1 and a description for each picture is presented in row 2. Is there a way to change the color of the text associated with its picture (row 2) when the user moves the mouse over the picture in (row 1) ?

What I have tried:

I have not tried anything yet, I do not know where to begin.

推荐答案

当然是.. 。

第一步是计算本控件每个子面板的尺寸和位置。每次控件的大小更改或控件内的ClientSize发生更改时,都要执行此计算。

现在您必须使用此控件的事件 - 也许是MouseMove。这将为您提供鼠标的当前位置。

至少您只需要检查鼠标当前位于哪个子面板内。



但最好的方法是自定义Control并在其中执行所有必需的计算(和动画)。
Yes of course ...
The first Step is to calculate the Size and the Location of each Sub-Panel of this Control. This Calculation is to be done each time the Size of the Control changes or the ClientSize inside the Control changes.
Now you have to work with the Events of this Control - perhaps MouseMove. This will give you the current location of the Mouse.
At least you only need to check inside which Sub-Panel the Mouse currently is located.

But the best way will be to customize the Control and do all the required Calculation (and Animation) inside it.


这篇关于Tablelayoutpanel - 鼠标悬停效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆