Question : Resize all controls before form shows

I have a form with multiple tabs and each tab has multiple controls.
When the form opens it is maximized.
I've tried hiding the form, setting opacity to 0, setting doublebuffer = true but the controls are still resizing when the form is shown.
Any ideas how to get the controls to resize without the user having to watch everything?
Thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
''''''  Where I launch form
 
      '  ft.Opacity = 0
            ft.Show()
            Application.DoEvents() 'ft.Hide()
            ft.SetPanelText()
            ft.SizeTabControl(0)
            ft.Session0Dirty = False
            ' ft.Opacity = 100
 
 
'''''SizeTabControl(0) procedure code
 
        For Each cnt1 As Control In spl.Panel1.Controls
 
            If TypeOf cnt1 Is FarPoint.Win.Spread.FpSpread Then
                Dim cnt As FarPoint.Win.Spread.FpSpread = CType(cnt1, FarPoint.Win.Spread.FpSpread)
                cR.Cnt = cnt
 
                If InStr(cnt.Name, "Rear") Or InStr(cnt.Name, "TiresR") Then
                    cnt.Left = 5
                End If
                cnt.BackColor = Color.Transparent
                cnt.Sheets(0).DefaultStyle.BackColor = Color.Transparent
                cnt.BorderStyle = BorderStyle.None
                cnt.ActiveSheet.GrayAreaBackColor = Color.Transparent
 
                If Not InStr(cnt.Name, "Front") Or Not InStr(cnt.Name, "Rear") Or Not InStr(cnt.Name, "Tires") Then
                    cR.ResizeControls(sw)
                Else
                    iLeft = fpFront.Left + fpFront.Width
                    iSpaceAvail = fpRear.Left - iLeft
 
                    cR.ResizeMidControls(iSpaceAvail, iLeft, sw)
                    'iMidWidth = cnt.Width
                    'iMidLeft = cnt.Left
                End If
 
            End If
 
        Next
 
 
        For Each cnt1 As Control In spl.Panel2.Controls
 
            If TypeOf cnt1 Is FarPoint.Win.Spread.FpSpread Then
                Dim cnt As FarPoint.Win.Spread.FpSpread = CType(cnt1, FarPoint.Win.Spread.FpSpread)
                cR.Cnt = cnt
 
                If InStr(cnt.Name, "Rear") Then
                    cnt.Left = 5
                End If
                cnt.BackColor = Color.Transparent
                cnt.Sheets(0).DefaultStyle.BackColor = Color.Transparent
                cnt.BorderStyle = BorderStyle.None
                cnt.ActiveSheet.GrayAreaBackColor = Color.Transparent
 
                If Not InStr(cnt.Name, "Front") Or Not InStr(cnt.Name, "Rear") Or Not InStr(cnt.Name, "Tires") Then
                    cR.ResizeControls(sw)
                Else
                    iLeft = fpFront.Left + fpFront.Width
                    iSpaceAvail = fpRear.Left - iLeft
 
                    cR.ResizeMidControls(iSpaceAvail, iLeft, sw)
                    'iMidWidth = cnt.Width
                    'iMidLeft = cnt.Left
                End If
 
            End If
 
        Next
 
''''ResizeControls(sw)  procedure
 
 Public Sub ResizeControls(ByVal iSplitWidth As Integer)
        Dim sw As Integer = iSplitWidth
        Dim cnt As FarPoint.Win.Spread.FpSpread
 
        If TypeOf mControl Is FarPoint.Win.Spread.FpSpread Then
 
            cnt = mControl
            sw = sw / 4
            'w = sw / 6
            'sw = sw - w
            mControl.Width = sw - 10
 
            If InStr(mControl.Name, "Front") Or InStr(mControl.Name, "TiresF") Then
                Dim iLeft As Integer = (iSplitWidth - mControl.Width) - 10
                mControl.Left = iLeft
 
            End If
 
 
            ResizeColumns()
 
        End If
 
 
    End Sub
 
 
''''ResizeColumns() procedure
 
Public Sub ResizeColumns()
        Dim iTotSize As Integer
        Dim iCol As Integer
        Dim i As Integer
        Dim iPad As Integer = 0
        Dim iScrollWidth As Integer = 0
        Dim cnt As FarPoint.Win.Spread.FpSpread
        Dim iCntWidth As Integer = 0
        Dim iColWidth As Integer = 0
 
        If TypeOf mControl Is FarPoint.Win.Spread.FpSpread Then
 
            cnt = mControl
            iCntWidth = cnt.Width
            i = cnt.ActiveSheet.RowHeader.Columns(0).Width
            i = i + cnt.ActiveSheet.Columns(1).Width
            'We have the width of the hidden and label column
            iColWidth = iCntWidth - i
            If cnt.ActiveSheet.ColumnCount - 1 > 2 Then
                iColWidth = iColWidth / 2
            End If
            'iColWidth = iColWidth /
 
            With cnt
                Try
 
 
 
                    If InStr(mControl.Name, "Tires") Then
                        iTotSize = cnt.ActiveSheet.Columns(1).Width
                        iTotSize = cnt.Width - iTotSize
                        iTotSize = iTotSize / 2
                        'get the width of the column that has text
 
                        If (cnt.BorderStyle = BorderStyle.Fixed3D) Then
                            iPad = 4
                        End If
 
                        If (cnt.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.Always Or cnt.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.AsNeeded) Then
                            iScrollWidth = cnt.VerticalScrollBarWidth
                        End If
 
                        For iCol = 2 To cnt.ActiveSheet.Columns.Count - 1
                            cnt.ActiveSheet.Columns(iCol).Width = iTotSize - 10 'cnt.Width - (iTotSize + iPad + iScrollWidth) / 2
                        Next
 
                    Else
                        If (cnt.BorderStyle = BorderStyle.Fixed3D) Then
                            iPad = 4
                            iPad = iPad / 2
                        End If
 
                        If (cnt.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.Always Or cnt.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.AsNeeded) Then
                            iScrollWidth = cnt.VerticalScrollBarWidth
                            iScrollWidth = iScrollWidth / 2
                        End If
 
                        For iCol = 2 To cnt.ActiveSheet.Columns.Count - 1
                            'iTotSize += cnt.ActiveSheet.Columns(iCol).Width
                            ''cnt.ActiveSheet.Columns(cnt.ActiveSheet.Columns.Count - 1).Width = cnt.Width - ((iTotSize + i + iPad + iScrollWidth) - (i / 3))
                            cnt.ActiveSheet.Columns(iCol).Width = iColWidth - iScrollWidth - iPad
                        Next
 
 
                        ' cnt.ActiveSheet.Columns(cnt.ActiveSheet.Columns.Count - 1).Width = cnt.Width - ((iTotSize + i + iPad + iScrollWidth) - (i / 3))
                    End If
                Catch ex As Exception
 
                End Try
 
            End With
 
        End If
 
    End Sub

Answer : Resize all controls before form shows

I found something that works.  Right after Show I set the tabcontrol.visible = false and then when everything is done, I show it.
It's much cleaner looking, I will probably place a label over the form saying loading or something.
Thanks for your help.
Random Solutions  
 
programming4us programming4us