[RESOLVED] UserControl Property Value Limit
I am making an UserControl which has several properties. One of them should have a specific range of the value - it should only be possible to set the value of the property with a number from 1 to 255. 0 should not be possible, because some calculations are done in which is divided by this property's value. I thought I could use a Byte as type, but a Byte can contain 0 as well. I would like to be able to set a limit for the value of this property, and that an error is shown in the Designer when, in this case, 0 is entered. I mean an error window like you get when filling in 0 for the interval of a Timer. Is this possible with an UserControl as well?
Thanks in advance.
Re: UserControl Property Value Limit
try this:
vb Code:
Private _testProperty As Integer
Public Property testProperty() As Integer
Get
Return _testProperty
End Get
Set(ByVal value As Integer)
If value >= 1 AndAlso value <= 255 Then
_testProperty = value
Else
Throw New ArgumentOutOfRangeException("Value must be between 1 and 255")
End If
End Set
End Property
Re: UserControl Property Value Limit
It works perfectly, exactly what I wanted! Thanks! :wave: