M
M O J O
Hi,
I can't figure out how to use the DesigMode property. I've searched Google
and not found a soilid solution. Therefor I ask you - what is the propper
way to find out if I'm in DesignMode???
Here's my test code - I'm trying to inheriting the textbox, so when I place
it on my form, I want the backcolor of the texbbox to change to yellow....
Public Class MyTextBox
Inherits System.Windows.Forms.TextBox
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
If Me.DesignMode Then
Me.BackColor = System.Drawing.Color.Yellow
Else
Me.BackColor = System.Drawing.Color.Red
End If
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
#End Region
End Class
The only solution I found was to use the function instead of DesignMode:
Private Function MeInDesignMode() As Boolean
MsgBox(Process.GetCurrentProcess.ProcessName)
Return Process.GetCurrentProcess.ProcessName.ToLower = "devenv"
End Function
..... but I don't think this is a solid solution.
Any ideas?????
Thanks!
M O J O
I can't figure out how to use the DesigMode property. I've searched Google
and not found a soilid solution. Therefor I ask you - what is the propper
way to find out if I'm in DesignMode???
Here's my test code - I'm trying to inheriting the textbox, so when I place
it on my form, I want the backcolor of the texbbox to change to yellow....
Public Class MyTextBox
Inherits System.Windows.Forms.TextBox
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
If Me.DesignMode Then
Me.BackColor = System.Drawing.Color.Yellow
Else
Me.BackColor = System.Drawing.Color.Red
End If
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
#End Region
End Class
The only solution I found was to use the function instead of DesignMode:
Private Function MeInDesignMode() As Boolean
MsgBox(Process.GetCurrentProcess.ProcessName)
Return Process.GetCurrentProcess.ProcessName.ToLower = "devenv"
End Function
..... but I don't think this is a solid solution.
Any ideas?????
Thanks!
M O J O