Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a variable that can only be set to certain numbers (integers and decimals) and that gets assigned by the user using a property grid. What I want is something that behaves like an Enum, where the users can select from a a drop down list of acceptable values. However enums don't see to support non integer numeric input. Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
147 views
Welcome To Ask or Share your Answers For Others

1 Answer

Ended up doing get/set and just changing the value if it's outside the acceptable range.

<DataMember()>
<DisplayName("Fisheye Angle")>
<Description("This value indicates the angle used in the fisheye view, if it is enabled.  The acceptable range is 45 to 360 degrees with 180 degrees being the default. ")>
<DefaultValue(180)>
Public Property FisheyeAngle As Double
    Get
        Return _FisheyeAngle
    End Get
    Set(value As Double)
        If value < 45 Then
            _FisheyeAngle = 45
        ElseIf value > 360 Then
            _FisheyeAngle = 360
        Else
            _FisheyeAngle = value
        End If
    End Set
End Property

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...