A
Academia
Can you see what is wrong with the code below.
Or suggest a better way.
Sometimes when I know I'm in the Designer I hit the bottom MessageBox
I think it might be because Site has not been set yet
Because I think it might happen while InitializeComponent is setting
properties and/or when OnLoad is running.
Thanks for any help
Public Shared Function IsDesign(ByVal c As Control) As Boolean
If c Is Nothing Then
MessageBox.Show("C is Nothing"...
End If
Dim nextControl As Control = c
Dim site As ISite
While nextControl IsNot Nothing
site = nextControl.Site
If site IsNot Nothing Then
If site.DesignMode Then Return True
End If
nextControl = nextControl.Parent
End While
MessageBox.Show(" Return False " ...
Return False
End Function
Or suggest a better way.
Sometimes when I know I'm in the Designer I hit the bottom MessageBox
I think it might be because Site has not been set yet
Because I think it might happen while InitializeComponent is setting
properties and/or when OnLoad is running.
Thanks for any help
Public Shared Function IsDesign(ByVal c As Control) As Boolean
If c Is Nothing Then
MessageBox.Show("C is Nothing"...
End If
Dim nextControl As Control = c
Dim site As ISite
While nextControl IsNot Nothing
site = nextControl.Site
If site IsNot Nothing Then
If site.DesignMode Then Return True
End If
nextControl = nextControl.Parent
End While
MessageBox.Show(" Return False " ...
Return False
End Function