Problem positioning resized form on a TabPage

Torquinian 1 Reputation point
2022-09-23T07:42:00.073+00:00

I have a Project which has a main Form which uses part of the screen as Tab Pages.
I then load other Forms into the Tab Pages.
The problem is that the users are using larger screens that the one that I am developing on and I need to increase the size of the loaded Forms to make it easier for them to read.

I can make the Controls larger on the Forms but the Form stays the same size, so Controls to the right hand side and down at the bottom are cut off.
The enlarged Form is displayed at the top left of the Tab Page, as required.
If I then use the Size command to make the Form larger, it does make it larger but moves the Form into roughly the centre of the Tab Page, once again cutting off Controls to the right hand side and down at the bottom.
Does anyone have any idea how I can keep the Form at the top left of the Tab Page?
244203-resize.txtUsing Location = new Point (0,0) has no effect.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. LesHay 7,126 Reputation points
    2022-09-23T13:33:17.423+00:00

    Hi
    There is a LOT more to it than this stand alone simple example I show below, but maybe this will help.
    This example shows a Button on the Form2 in TabPage(1) which retains relative position when Form1 is resized etc. You already have the means to resize child controls in Form2 so using that in conjuction may be what you want.

    ' Form1 with a TabControl  
    ' which has TabPage(0) and  
    ' TabPage(1)  
    ' and a Form2  
    Option Strict On  
    Option Explicit On  
    Public Class Form1  
      Dim WithEvents butt As New Button  
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
        With Form2  
          .Text = "TEST FORM"  
          .Dock = DockStyle.Fill  
          .TopLevel = False  
          .BackColor = Color.Red  
          .Show()  
        End With  
        With butt  
          .AutoSize = True  
          .Font = New Font(.Font.FontFamily, 20)  
          .Text = "New Button"  
          .Location = New Point(TabControl1.TabPages(1).Right - butt.Width - 30, 20)  
          .BackColor = Color.LightGreen  
          .Anchor = AnchorStyles.Top Or AnchorStyles.Right  
        End With  
        TabControl1.TabPages(1).Controls.Add(Form2)  
        Form2.Controls.Add(butt)  
      End Sub  
    End Class  
      
    

  2. Torquinian 1 Reputation point
    2022-09-26T08:23:50.323+00:00

    Hi,
    The Form Properties on the Form being added are shown in the files attached.
    The Form being shown in the Tab Page already exists.
    Working on your other comments now.
    244727-properties1.jpg244733-properties2.jpg

    0 comments No comments

  3. Torquinian 1 Reputation point
    2022-09-26T11:08:54.687+00:00

    I have managed to catch a simple Form while it is being initially Shown in the Tab Page (Display1) and when it has finished being Shown (Display2).
    In longer Forms, Controls at the bottom of the Form are lost in addition to those at the right-hand side.
    I have not tried to resize the Controls in the DataGrid and Panel as yet.
    244794-display1.jpg244764-display2.jpg


  4. Torquinian 1 Reputation point
    2022-09-26T13:56:39.637+00:00

    The answer to why is simple - Originally, the Forms being added to the TabPages were centralised in the TabPage and not resized, and that has worked fine for (literally) years, so I was expecting that locating the form in a different position and making it larger would not be such a problem.

    I will use the code you posted and let you know the results when I have done so.


  5. Torquinian 1 Reputation point
    2022-10-06T13:54:03.527+00:00

    Not as yet, because I have not had the time to try it out. The customer's priorities have changed, so that I am concentrating on a problem (Which I have posted on MSDN) about having the full file location associated with an attachment showing at the receiving person's end instead of just the simple filename.
    I will definitely come back to this as I know the customer will be back to this as soon as the filename problem is solved.

    0 comments No comments