Question How to make a form smaller than 27 x 112?

miwtech

Member
Joined
Oct 17, 2008
Messages
5
Programming Experience
3-5
I've torn what's left of my hair out over this.

I'm making an app with several forms and wanted to add a label to each form that, when double clicked, would resize the form to 10 x 10 pixels.

ControlBox, MaximizeBox, MinimizeBox, properties are set to false so there is no title bar. No text or icon. MinimumSize is set to 0,0.

I made a new project that consists of one form with one label to make sure there was nothing in my code causing the problem but still every time I double click the label the form is resized to 27 pixels high by 112 wide.

Any ideas why this would be?
 
Check the FormBorderStyle Property and the Text properties for the form. If you set the text empty and don't change the FormBorderStyle with the other combinations you listed the designer will show no window title bar but it is still there.

Try changing the FormBorderStyle to None.
 
The text field for the form is empty. Setting the FormBorderStyle to "None" does not change anything.

It should also be noted that I can resize the form to 10 x 10 in the designer but it still appears at 27 x 112 when run.
 
I admint that the first things I suggested came from VS2008, then I logged into my other computer that has VS2003. The same settings worked just fine.
Here is my VS2003 Form code that does take my windows form that starts at a size of 292, 266 and when you double click the label it does resizes to a 10 x 10 square. Even with text in the text property it still works.

VB.NET:
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(64, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Label1"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.ControlBox = False
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub LabelDoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.DoubleClick
        Me.Size = New Size(10, 10)
    End Sub
 
Back
Top