C# MDI - 如何防止滚动条?
最好用图像来显示,我可以将表单拖离 MDI 父级的边缘,然后就会出现滚动条。
我宁愿将子窗体锁定到父窗体的区域。
我已经完成了寻找解决方案的工作,(其中很多都是两年多前回答的,所以我希望它们已经过时)并且只遇到人们检查“移动”事件的坐标......很好,但是如果我有怎么办20 份表格.. 或 100 份表格。我无法对所有这些进行编码,这有点愚蠢。当然,我可以在父窗体上设置一个属性。
Best shown with an image, I can drag the forms off the edge of the MDI parent, and scroll bars appear.
Id much rather that child forms are locked to the area of the Parent form.
Ive done searching for a solution, (A lot of these are answered 2+ years ago, so im hoping they are outdated) and only come across people checking co-ordinates on the Move event.... Great, but what if I have 20 forms.. or 100 forms. I cant code all of them, its a bit silly. Surely there is a property somewhere I can just set on the parent form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第 1 步:
您应该创建一个从 NativeWindow 类继承的新类并重写其 WndProc 方法。
第 2 步:
在 MDI 窗体中创建这个新类的新对象,并将 MDIClient 控件传递给其构造函数。
第 1 步代码:
第 2 步代码:
Step 1:
You should create a new class inherited from NativeWindow class and override its WndProc method.
Step 2:
In your MDI form create a new object of this new class and pass the MDIClient control to its constructor.
Step 1 code:
Step 2 code:
你可以做这样的事情...
步骤!:你必须制作基本表单(如用户控件)
并将此代码放入该表单中
,然后在每个表单中你必须这样指定...
确保所有子表单size 应该是以基本形式指定的大小
minsize 是 0,0
max Sixze 也是 0,0
起始位置 - windowsdefaultlocation
windowstate - 正常
我希望它能帮助你..
you can do something like this...
Step !: you have to make base form( like user control)
and place this code in that form
and then in every form you have to specify like this...
Make sure all your child forms size is should be size specified in base form
minsize is 0,0
max sixze is also 0,0
startposition - windowsdefaultlocation
windowstate - normal
I hope it will helps you ..
您始终可以覆盖父类中的移动功能,然后让所有表单继承自该类。
没有神奇的 API/属性(据我所知,如果我错了,抱歉)可以告诉 MDI 父级将子级锁定在其范围内。
You could always override the move functionality in a parent class, then have all of your forms inherit from that class.
Theres no magic API/property (that I know of, apologies if I'm wrong) to tell an MDI parent to lock children within its bounds.