达到限制宽度大小时,禁用调整大小的表单宽度 [英] Disable resize form width when comes to a limit width size

查看:87
本文介绍了达到限制宽度大小时,禁用调整大小的表单宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

您能帮助我如何禁止用户重新调整表单宽度吗?
场景:
我想在边界或极限宽度处设置给定宽度
用户可以调整大小.
用户可以重新调整表单大小,除非达到我的表单极限宽度...

你能帮我吗...
抱歉英语不好...:O
在此先感谢....

Hello Guys,

Can you help me on how to disable the user to re-size the form width.
Scenario:
I have want to set a given width where it is the boundary or the limit width where
the user can re-size.
User can re-size the form except when it have reach to my limit width of the form...

Can you please help me...
Sorry for poor English... :O
Thanks in advance....

推荐答案

只需设置表单的 MinimumSize属性 [
Just set the form''s MaximumSize property[^] and MinimumSize property[^].


我认为这是一个WinForms应用程序.窗口将具有Resize事件,该事件将在调整控件大小时触发(足够有趣).您可以使用此事件来检查表单的大小,如果它大于所需的最大大小,则可以将其强制为正确的大小.像这样的东西(伪C#)

I take it this is a WinForms app. The window will have a Resize event which fires when the control gets resized (funnily enough). You could use this event to check the size of the form, and if it is greater than the max size you want just force it to the correct size . Something like this(pseudo C#)

void Resize(object sender, eventArgs e)
        {
            if (this.Width >= MaxWidth)
            {
                this.Width = MaxWidth;
            }
        }



希望这会有所帮助

[更新]

这是VB版本



Hope this helps

[UPDATE]

Here is a VB version

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
       Dim maxWidth As Integer = 800
       If Me.Width >= maxWidth Then
           Me.Width = maxWidth
       End If
   End Sub



祝你好运



Good Luck


这篇关于达到限制宽度大小时,禁用调整大小的表单宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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