限制数字输入vb属性网格

时间:2015-03-24 19:33:47

标签: vb.net enums

我有一个变量,只能设置为某些数字(整数和小数),并由用户使用属性网格分配。我想要的是行为类似于Enum的东西,用户可以从可接受值的下拉列表中进行选择。但是enums不支持非整数数字输入。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

结束get / set,如果超出可接受的范围,只需更改值。

<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