I'm creating a custom progress bar with a property
Public Class CustomProgressBar : Inherits ProgressBar
Private _State As ProgressStates
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As Int32
End Function
<Category("Appearance")> _
<DefaultValue(ProgressStates.Normal)> _
<Description("The progress state, Red=Error, Yellow=Warning, Green=Normal")> _
Public Property State As ProgressStates
Get
Return _State
End Get
Set(value As ProgressStates)
_State = value
SendMessage(MyBase.Handle, 1040, value, 0)
End Set
End Property
End Class
ProgressStates
Public Enum ProgressStates
Normal = 1
[Error] = 2
Warning = 3
End Enum
In the designer I set my custom property to Error
and it works fine (in the designer), but when I run my application, progress value sets automatically to 0 and property is not applied