限制数字输入vb属性网格 [英] Restrict numeric input vb property grid
本文介绍了限制数字输入vb属性网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
完成取得/设置,只有在超出可接受的范围内才能更改值。
< DataMember()>
< DisplayName(鱼眼角度)>
<说明(此值表示鱼眼视图中使用的角度,如果启用,可接受范围为45至360度,默认值为180度。)>
< DefaultValue(180)>
公共财产FisheyeAngle As Double
获取
返回_FisheyeAngle
结束Get
Set(value As Double)
如果value< 45然后
_FisheyeAngle = 45
ElseIf value> 360然后
_FisheyeAngle = 360
Else
_FisheyeAngle = value
结束如果
结束集
结束属性
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?
解决方案
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
这篇关于限制数字输入vb属性网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文