I am getting dialog box "Property value is not valid" when the Control is in Design Mode (Visual Studio 2008) and I try to change the Property's Value.
Here is the property in question:
<Description("Gets/Sets the visibillity of the SaveButton of Control")> _
Property ShowSaveButton() As Boolean
Get
Return _SaveVisible
End Get
Set(ByVal Value As Boolean)
_SaveVisible = Value
If Value Then
If Model.CommonUser.CurrentUser.IsReadOnly = False Then
CreateButton("SaveButton", "Save", enBeneButtons.enSaveButton)
End If
Else
DoRemove(enBeneButtons.enSaveButton)
End If
End Set
End Property
The error detail shows "CommonUser must be initialized first.", which of course is pointing at this code.
If Model.CommonUser.CurrentUser.IsReadOnly = False Then
CreateButton("SaveButton", "Save", enBeneButtons.enSaveButton)
End If
Is there some sort of if statement that can be used to skip around code when in Design Mode. VisualStudioDesignMode is used below.
If VisualStudioDesignMode = True Then
CreateButton("SaveButton", "Save", enBeneButtons.enSaveButton)
ElseIf Model.CommonUser.CurrentUser.IsReadOnly = False Then
CreateButton("SaveButton", "Save", enBeneButtons.enSaveButton)
End If
Again, this dialog box comes up in VS 2008 design mode. The logic works when the application is running.