in vsintegration/src/FSharp.ProjectSystem.PropertyPages/PropertyPages/PropertyControlData.vb [1104:1200]
Protected Sub SetControlValue(ByVal value As Object)
Dim control As System.Windows.Forms.Control = Me.FormControl
Dim _TypeConverter As TypeConverter = Nothing
If PropDesc IsNot Nothing Then
_TypeConverter = PropDesc.Converter
End If
Debug.Assert(control IsNot Nothing, "Unexpected null argument")
If TypeOf control Is System.Windows.Forms.TextBox Then
If value Is PropertyControlData.Indeterminate Then
value = ""
Else
If (_TypeConverter IsNot Nothing) Then
value = _TypeConverter.ConvertToString(value)
End If
End If
DirectCast(control, System.Windows.Forms.TextBox).Text = CType(value, String)
ElseIf TypeOf control Is System.Windows.Forms.ComboBox Then
Dim cbx As ComboBox = DirectCast(control, System.Windows.Forms.ComboBox)
Dim StringValue As String = ""
If value Is PropertyControlData.Indeterminate Then
StringValue = ""
ElseIf (_TypeConverter IsNot Nothing) Then
StringValue = _TypeConverter.ConvertToString(value)
ElseIf TypeOf value Is String Then
StringValue = value.ToString()
End If
Debug.Assert(TypeOf StringValue Is String, "value should be string")
If _TypeConverter IsNot Nothing AndAlso _TypeConverter.GetStandardValuesSupported Then
cbx.Items.Clear()
For Each o As Object In _TypeConverter.GetStandardValues()
cbx.Items.Add(_TypeConverter.ConvertToString(o))
Next
End If
If value IsNot PropertyControlData.Indeterminate Then
cbx.SelectedItem = StringValue
If cbx.DropDownStyle = ComboBoxStyle.DropDownList Then
If cbx.SelectedIndex = -1 Then
cbx.SelectedIndex = cbx.Items.Add(StringValue)
cbx.SelectedItem = StringValue
End If
Else
If cbx.SelectedIndex = -1 Then
cbx.Text = StringValue
End If
End If
Else
cbx.SelectedIndex = -1
End If
ElseIf TypeOf control Is System.Windows.Forms.CheckBox Then
Dim chk As CheckBox = DirectCast(control, System.Windows.Forms.CheckBox)
If value Is PropertyControlData.Indeterminate Then
chk.CheckState = CheckState.Indeterminate
Else
chk.CheckState = CheckState.Unchecked
If TypeOf value Is Boolean Then
chk.Checked = DirectCast(value, Boolean)
ElseIf _TypeConverter IsNot Nothing AndAlso _TypeConverter.CanConvertTo(GetType(Boolean)) Then
chk.Checked = DirectCast(_TypeConverter.ConvertTo(value, GetType(Boolean)), Boolean)
Else
Try
chk.Checked = CBool(value)
Catch ex As Exception
chk.CheckState = CheckState.Indeterminate
End Try
End If
End If
ElseIf TypeOf control Is System.Windows.Forms.Label Then
If value Is PropertyControlData.Indeterminate Then
DirectCast(control, System.Windows.Forms.Label).Text = ""
Else
DirectCast(control, System.Windows.Forms.Label).Text = CType(value, String)
End If
ElseIf control Is Nothing Then
Debug.Fail("PropPageUserControlBase::InitPage(): Unexpected null control value")
End If
End Sub