none
Form and Control Sizing RRS feed

  • Question

  • I have the form below:

    The form meets the requirements I have set for it, but some of the measurements I completely fail to under stand

    The form size is set at (590, 340)

    The panel size is (640, 320)

    The DGV size is (627, 300)

    Why is the width of the form less than the DGV and Panel?  It appears to me that the form uses a different form of measurement than the DGV or Panel


    gwboolean



    • Edited by gwboolean Saturday, September 8, 2018 6:19 PM
    Saturday, September 8, 2018 6:18 PM

All replies

  • Hi

    The dimensions you mention do not seem to be for the image you show.

    When I try it using thise dimensions, I get the Panel taking up ALL of the Form real estate and when drag resizing the Form, get the DGV below.  I located the DGV below the Panel)


    Regards Les, Livingston, Scotland

    Saturday, September 8, 2018 6:48 PM
  • The usual reason that it doesn't look right to you is probably because I have completely missed something.

    Below is the whole code sequence for setting the properties of that form I cannot see anything wrong with what I have done.

            Public Sub SetState(ByVal Appstate As String)
                'Format form
                Select Case Appstate
                    Case "View"
                        'Form
                        With frmProcessList
                            .Size = New Size(590, 340)
                            .BackColor = CType(_objFormBackColor, Color)
                            .ForeColor = CType(_objFormForeColor, Color)
                            .Font = New Font("Times New Roman", 12, FontStyle.Regular)
                            .StartPosition = FormStartPosition.CenterScreen
                            '.pnlProcessList.BorderColor = CType(glbobjPnlLine, Color)
                            .tlsGeneralForm.BackColor = CType(_objToolBackColor, Color)
                            'Toolbar
                            .Location = New System.Drawing.Point(540, 100)
                            .Separator2.Visible = False
                            .btnPrint.Visible = False
                            .btnPrint.Enabled = False
                            .btnPrint.Text = "Print"
                            .btnOne.Visible = False
                            .btnOne.Enabled = False
                            .btnOne.Text = "All" & vbNewLine & "By CR"
                            .btnTwo.Visible = True
                            .btnTwo.Enabled = True
                            .btnTwo.Text = "All" & vbNewLine & "By Process"
                            .btnThree.Visible = True
                            .btnThree.Enabled = True
                            .btnThree.Text = "In Process"
                            .btnFour.Visible = True
                            .btnFour.Enabled = True
                            .btnFour.Text = "Effective"
                            .btnFive.Visible = True
                            .btnFive.Enabled = True
                            .btnFive.Text = "Obsolete"
                            .btnSix.Visible = False
                            .btnSave.Enabled = False
                            .btnSave.Text = "Save"
                            .btnExit.Enabled = True
                            .btnExit.Text = "Exit"
                            .btnHelp.Enabled = True
                            .btnHelp.Text = "Help"
                        End With
                        'Panel
                        With frmProcessList.pnlProcessList
                            .Size = New Size(640, 320)
                            .Location = New Point(12, 50)
                        End With
                        'DGV Load
                        With frmProcessList.dgvProcessList
                            'Columns
                            .BackgroundColor = CType(_objDGVBackColor, Color)
                            .BorderStyle = BorderStyle.None
                            .EnableHeadersVisualStyles = False
                            .ColumnHeadersVisible = True
                            .RowHeadersVisible = False
                            'Columns/Headers
                            .ColumnHeadersDefaultCellStyle.Font = New Font("Times New Roman", 11, FontStyle.Bold)
                            .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                            .ColumnHeadersDefaultCellStyle.ForeColor = CType(_objDGVHeaderForeColor, Color)
                            .ColumnHeadersDefaultCellStyle.BackColor = CType(_objDGVHeaderBackColor, Color)
                            'DGV
                            .ReadOnly = False
                            .AllowUserToAddRows = False
                            .AllowUserToDeleteRows = False
                            .AllowUserToResizeColumns = False
                            .AllowUserToResizeRows = False
                            .Size = New Size(627, 300)
                            .Location = New Point(8, 12)
                            'Cells
                            .DefaultCellStyle.Font = New Font("Times New Roman", 11)
                            .DefaultCellStyle.ForeColor = CType(_objDGVCellForeColor, Color)
                            .DefaultCellStyle.BackColor = CType(_objDGVCellBackColor, Color)
                            .DefaultCellStyle.SelectionBackColor = CType(_objDGVSelectBackColor, Color)
                            .DefaultCellStyle.SelectionForeColor = CType(_objDGVSelectForeColor, Color)
                            .AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
                            .Columns(0).Visible = True
                            .Columns(0).HeaderText = "Change" & vbNewLine & "ID"
                            .Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                            .Columns(0).DefaultCellStyle.WrapMode = DataGridViewTriState.True
                            .Columns(0).Width = 150
                            .Columns(0).DisplayIndex = 0
                            .Columns(1).Visible = True
                            .Columns(1).HeaderText = "Process" & vbNewLine & "ID"
                            .Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                            .Columns(1).DefaultCellStyle.WrapMode = DataGridViewTriState.True
                            .Columns(1).Width = 150
                            .Columns(1).DisplayIndex = 1
                            .Columns(2).Visible = True
                            .Columns(2).HeaderText = "Title/Name"
                            .Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
                            .Columns(2).DefaultCellStyle.WrapMode = DataGridViewTriState.True
                            .Columns(2).Width = 250
                            .Columns(2).DisplayIndex = 2
                            .Columns(3).Visible = True
                            .Columns(3).HeaderText = "Revision"
                            .Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                            .Columns(3).DefaultCellStyle.WrapMode = DataGridViewTriState.True
                            .Columns(3).Width = 75
                            .Columns(3).DisplayIndex = 3
                            .Columns(4).Visible = False
                            .Columns(5).Visible = False
                            .Columns(6).Visible = False
                            .Columns(7).Visible = False
                            .Columns(8).Visible = False
                            .Columns(9).Visible = False
                            .Columns(10).Visible = False
                            .Columns(11).Visible = False
                            .Columns(12).Visible = False
                            .Columns(13).Visible = False
                            .Columns(14).Visible = False
                            .Columns(15).Visible = False
                            .Columns(16).Visible = False
                            .Columns(17).Visible = False
                            .Columns(18).Visible = False
                            .Columns(19).Visible = False
                            .Columns(20).Visible = False
                            .Columns(21).Visible = False
                            .Columns(22).Visible = False
                        End With
                End Select
            End Sub


    gwboolean

    Saturday, September 8, 2018 8:15 PM
  • Hi

    Yeah, lots there. I won't try to recreate your Form.

    One thing to check:

    Have you adjusted the PC Scale andLayout settings (here my setting is 225%) and that in itself can be problematic with Forms/Controls etc.

    *

    If it is different from 100%, try setting 100% see if it has a positive effect.


    Regards Les, Livingston, Scotland


    • Edited by leshay Saturday, September 8, 2018 9:03 PM
    Saturday, September 8, 2018 9:02 PM
  • I will definitely give that a look.  I have had a few problems with scale in the past.  Thanks

    gwboolean

    Saturday, September 8, 2018 9:14 PM
  • I have the form below:

    The form meets the requirements I have set for it, but some of the measurements I completely fail to under stand

    The form size is set at (590, 340)

    The panel size is (640, 320)

    The DGV size is (627, 300)

    Why is the width of the form less than the DGV and Panel?  It appears to me that the form uses a different form of measurement than the DGV or Panel


    gwboolean



     This can be caused by increasing the Form's font size and having the Form's AutoScalingMode set to AutoScaleMode.Font which is the default mode.  When using the AutoScaleMode.Font mode,  the Form will scale it's size according to the Font.  So,  if you increase the Form's font size,  the Form will scale itself to a larger size.

     You could try setting the Form's AutoScaleMode to 'Dpi' or 'None'.  This should allow you to set the larger font and keep the form's size set to your normal size.  The (590x340) will make the form smaller than Panel and Dgv.

     For example,  here I set the Form's font and size according to your code and left the AutoScaleMode set to 'Font'.  The Dgv is brown and the Panel is Blue.

                .AutoScaleMode = AutoScaleMode.Font
                .Font = New Font("Times New Roman", 12, FontStyle.Regular)
    


     Now I set the AutoScaleMode to 'None'.  You can see the difference in the Form size.

                .AutoScaleMode = AutoScaleMode.None
                .Font = New Font("Times New Roman", 12, FontStyle.Regular)
    

     

    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, September 8, 2018 11:47 PM
    Saturday, September 8, 2018 11:08 PM