最小 Vb.net 表单大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17313916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:02:42  来源:igfitidea点击:

Minimum Vb.net Form size

vb.netwinforms

提问by sana naz

Can we shrink the width of form size less than 132 and height less than 38 Please help me about it.

我们可以缩小表单大小小于 132 和高度小于 38 的宽度吗 请帮助我。

Here is the code:

这是代码:

For i As Integer = 0 To meWidth
    If (Me.Width > 0) Then
        Me.Width = Me.Width - 20
        Me.Refresh()
        For FadeCount = 40 To 40 Step 20
            Me.Opacity = FadeCount / 100
            Threading.Thread.Sleep(10)
        Next
    Else
        Exit For
    End If
Next

采纳答案by SysDragon

You can define your minimun form size with the property Form.MinimumSize. Check the MSDN Documentation about it.

您可以使用属性定义最小表单大小Form.MinimumSize。查看有关它MSDN 文档

Basically:

基本上:

This property enables you to limit the size of a form to a specified minimum size. You can use this feature to prevent a user from sizing a window to an undesirable size. If this property is set to a Size object that is 0 in height and 0 in width, the form will have no minimum size beyond the limits set by Windows.

此属性使您能够将表单的大小限制为指定的最小大小。您可以使用此功能来防止用户将窗口大小调整为不合需要的大小。如果将此属性设置为高度为 0 且宽度为 0 的 Size 对象,则窗体将没有超出 Windows 设置的限制的最小尺寸。

回答by user1234960

I couldn't find this answer anywhere and I would like to share my solution:

我在任何地方都找不到这个答案,我想分享我的解决方案:

Me.Text = ""
Me.ControlBox = False
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.MinimumSize = New System.Drawing.Size(1, 1) 'HERE IS MY FIX
Me.Size = New System.Drawing.Size(200, 23)

By not allowing the MinimumSizeproperty to remain at (0,0) by default, it seems to have cleared this bug up for me.

MinimumSize默认情况下不允许属性保持在 (0,0),它似乎已经为我清除了这个错误。

回答by Dev I.A

U can Control Minimum Size : Example

你可以控制最小尺寸:示例

    Dim MinWidth As Integer = 396
    Dim MinHeigh As Integer = 369

    If Me.Width <= MinWidth Then
        Me.Width = MinWidth
    End If


    If Me.Height <= MinHeigh Then
        Me.Height = MinHeigh
    End If