标题本身就说明了一切。对于 VB,关键字
Nothing
与 False
相同。
此代码验证复选框是否为三态复选框,并设置默认值,
indeterminate
如果是“三态”,则为 false。
myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, Nothing, False)
结果是一样的,总是
False
。如何设置indeterminate
状态?
那
New Nullable(Of Boolean)
呢?
myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, New Nullable(Of Boolean), False)
或更短只是
New Boolean?
:
myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, New Boolean?, False)