如何禁用在VB.NET中移动的父窗体 [英] How to disable Parent form moved in VB.NET
本文介绍了如何禁用在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:
- 将以下代码添加到表单构造函数中:
- 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
.
无论如何,问题就解决了.自己决定是否真正想要.
Anyway, the problem is solved. Decide for yourself if you really want it.
这篇关于如何禁用在VB.NET中移动的父窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文