移动用户控制问题 [英] movable user control problem

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

问题描述

嗨.我在用户控件上有问题.我的用户控件是可移动的,但是最常见的是,当我将用户控件移动到表单内的其他位置时,我的用户控件消失了.我的用户控件闪烁.并且它超出了表单的边界.意思是,我无法查看其中的某些内容,因为它移动/超出了表格的边界. :)

Hi. I have a problem on the user control. My user control is movable, but most frequently, when I move the user control to other place inside the form, my user control disappear. My User control is flickering. And it exceeds within the boundary of the form. Meaning, I wasn''t able to view some of it because it moves/exceeds to the boundary of the form. :)

推荐答案

我没有看到代码,我想你是在对接问题上.

您遇到问题的原因有很多,
this.Controls.Add(usercontrol1)可能需要寻址.

此处 [此处 [
Without seeing code I would guess you are having docking issues.

There are several reasons for your problem,
this.Controls.Add(usercontrol1) may need addressing.

Here[^] is a MS link.

And Here[^] is c#Corner link.

I hope they help.

If not, please supply more information.


移动时,是从控件内部还是从表单中进行操作?

如果是前者(即this.Location = new Point(x,y);),那么您将需要某种方式从表格中传递其移动的限制.请记住,表单可以调整大小,因此控制限制可以更改.

如果是后者(即myControl.Locaion = new Point(x, y);),则需要在设置位置之前进行检查,并确保它在表单的主体之内.

抱歉,这似乎很明显,但这就是事实.如果您不检查限制并允许它们使用,那么它将无法正常工作!
When you move it, do you do so from within the control, or from the form?

If the former (i.e. this.Location = new Point(x,y);) then you will need to have some way to pass the limits of it''s movement through from the form. Remember that the form can be re-sized, and so the control limits are changeable.

If the latter (i.e. myControl.Locaion = new Point(x, y);) then you need to check before you set the location, and ensure it is within the body of the form.

Sorry if that seems obvious, but that''s the way it goes. If you don''t check limits and allow for them, then it ain''t going to work correctly!


这里是一种解决方案:
用户驱动的应用程序 [
Here is one solution:
User-driven applications[^]

It has the required functionality, and then some :)

Regards
Espen Harlinn


这篇关于移动用户控制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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