仅在面板内移动对象 [英] Move an object only inside a Panel

查看:74
本文介绍了仅在面板内移动对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我在C#中有一个包含两个面板的项目.第一面板不可调整大小或移动.第二个是相当大且可移动的.我希望第二个面板仅在第一个面板内部移动,并且当其边界与另一个面板相等时停止移动.

现在,当我移动第二个面板时,在通过第一个面板的边界并检查其坐标后,例如左= -20或顶部= -30,它恰好消失在第一个面板后面的某个地方.

请帮忙.谢谢.

Dear friends,

I have a project in C# with two panels. The first panel is not resizeble or movable. The second one is sizeable and movable. I want the second panel to move only inside the first panel, and when it''s borders are equal to the other panel, to stop moving.

When I move the second panel now, after passing the border of the first one and checking its coordinates, they are for example left = -20 or top = -30, it happens to dissapear somewhere behind the first panel.

Please help. Thank you.

推荐答案

当然它消失了.您需要处理移动事件,如果对象移动到其父对象的边界之外,则将其移回.
Of course it disappears. You need to handle the moving event and if the object moves past the bounds of it''s parent, move it back.


这篇关于仅在面板内移动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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