如何禁用在VB.NET中移动的父窗体 [英] How to disable Parent form moved in VB.NET

查看:72
本文介绍了如何禁用在VB.NET中移动的父窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个家长表格,但不允许移动此表格.但是我做不到.如果在VB6中可以设置属性Moveable = False,但在VB.NET中则没有此属性.

如何不允许用户移动表格?

请帮帮我.

在此先感谢

I have a parent form and I don''t allow to move this form. but i can not do this. If in VB6 I can set properties Moveable =False but in VB.NET there is no this properties.

How to do not allow user move form?

Please help me.

thanks in advance

推荐答案

简短的初步说明:表单之间没有父子关系. (我不是说MDI的父母和孩子,这不是同一回事,谁需要MDI?:-)尽管有所有者和所有者形式;我强烈建议主表单拥有所有表单,这有助于应用程序的完整性.

现在,关于防止表单拖动.很奇怪,这很容易实现:

A short preliminary note: there are not parent-child relationships between forms. (I don''t mean MDI parent and children, which is not the same thing, also, who needs MDI? :-)) There are owner and owned forms though; I would highly recommend to have all forms owned by the main form which helps application integrity.

Now, about preventing form dragging. Weird enough, this is ridiculously simple to achieve:

  1. 将以下代码添加到表单构造函数中:
  1. Add the following code to the the form constructor:
public NonMovableForm() {
   InitializeComponent();
   //add this:
   this.ControlBox = false;
   this.Text = null;
} //NonMovableForm



如果要对非主表单执行相同的操作,强烈建议添加ShowInTaskbar = false.

  • 如果确实需要它,请创建一个伪造的控件,模仿一个带有标题栏(或不带有关闭"按钮)的标题栏,并将其停靠在表单顶部.
  • 不要实现表格拖动. :-)
  • 准备好接受用户的多次投诉.
  • 盈利?我不确定-请参阅上面的项目.


  • If you want to do the same for a non-main form, I would highly recommend to add ShowInTaskbar = false.

  • If you really need it, create a fake control imitating a title bar with Close button on it (or not) and dock it to the top of the form.
  • Do not implement form dragging. :-)
  • Get ready to receive multiple complaints from the users.
  • PROFIT? I''m not sure — see the item above.


  • 无论如何,问题就解决了.自己决定是否真正想要.

    —SA



    Anyway, the problem is solved. Decide for yourself if you really want it.

    —SA


    这篇关于如何禁用在VB.NET中移动的父窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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