protected virtual void SetControlValue(Control control, Object value, String stringValue)
{
// Handle combobox explicitly
if (control is ComboBox) {
ComboBox cb = ((ComboBox)control);
if (cb.Created)
cb.SelectedValue = value;
else
this.BeginInvoke(new MethodInvoker(delegate {
cb.SelectedValue = value;
}));
return;
}
if (Munger.PutProperty(control, "Value", value))
return;
// There wasn't a Value property, or we couldn't set it, so set the text instead
try {
String valueAsString = value as String;
if (valueAsString == null)
control.Text = stringValue;
else
control.Text = valueAsString;
} catch (ArgumentOutOfRangeException) {
// The value couldn't be set via the Text property.
}
}