Mick,[color=blue]
> Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
> MyBase.OnResize(e)
>
> If LayingOut Then Return[/color]
You do realize that the Control.Layout event itself is "protected" by an
internal LayingOut flag. That you can use Control.SuspendLayout &
Control.ResumeLayout to control when the Control.Layout event is raized,
further you can use Control.PerformLayout to raise the Control.Layout event.
I would put all your code in the Layout event, then call PerformLayout in
the Load event, and possible the Resize Event if the Tab Control is not
playing nice with the Layout event.
Hope this helps
Jay
"Mick Doherty"
<EXCHANGE#WITH@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:eTQwiPqXEHA.1036@TK2MSFTNGP10.phx.gbl...[color=blue]
> a bit of a hack, but it's the best I could come up with:
>
> \\\
> 'Tabcontrol does not have a selectedtab and controls has not set zOrder
> until
> 'the form is visible. The resize event does fire before the form is[/color]
visible[color=blue]
> though.
> 'So this is to fix the null reference problems.
> Private LayingOut As Boolean = True
>
> Private Sub TabbedForm_Load(ByVal sender As Object, ByVal e As EventArgs)[/color]
_[color=blue]
> Handles[/color]
MyBase.Load[color=blue]
> LayingOut = False
> 'Now that the forms visible let's force a resize to align the[/color]
tabcontrols[color=blue]
> Me.Width += 1
> Me.Width -= 1
> End Sub
>
> Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
> MyBase.OnResize(e)
>
> If LayingOut Then Return
>
> Dim TC1zOrder, TC2zOrder As Integer
> TC1zOrder = Me.Controls.GetChildIndex(TabControl1)
> TC1zOrder = Me.Controls.GetChildIndex(TabControl2)
>
> If TC1zOrder > TC2zOrder Then
> RePositionTabControl(TabControl2)
> RePositionTabControl(TabControl1)
> RePositionTabControl(TabControl2)
> Else
> RePositionTabControl(TabControl1)
> RePositionTabControl(TabControl2)
> RePositionTabControl(TabControl1)
> End If
>
> End Sub
>
> Private Sub RePositionTabControl(ByVal tc As TabControl)
>
> If tc Is TabControl1 Then
> tc.Top = 0
> tc.Left = TabControl2.SelectedTab.Left - 2
> tc.Width = Me.ClientSize.Width - tc.Left
> tc.Height = Me.ClientSize.Height
> Else
> tc.Left = 0
> tc.Top = TabControl1.SelectedTab.Top - 2
> tc.Width = Me.ClientSize.Width
> tc.Height = Me.ClientSize.Height - tc.Top
> End If
>
> End Sub
> ///
>
> --
> Mick Doherty
>
http://dotnetrix.co.uk
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (
http://www.grisoft.com).
> Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
>
>[/color]