Aug 26, 2009, 9:47 PM
Adding custom editor for PropertyGridParameter in code-behind doesn't work.
Please note I'm not trying to create anything dynamically in an AjaxEvent - this is just in Page_Load.
Thanks,
Tim
protected void Page_Load(object sender, EventArgs e)
{
ImageLayer imageLayer = new ImageLayer();
PropertyGridParameterCollection propertyGridParameters = new PropertyGridParameterCollection();
foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(imageLayer))
{
object value = propertyDescriptor.GetValue(imageLayer);
PropertyGridParameter propertyGridParameter = new PropertyGridParameter(propertyDescriptor.DisplayName, (value != null) ? value.ToString() : "[Null]");
if (propertyDescriptor.PropertyType.IsEnum)
{
ComboBox comboBox = new ComboBox { EmptyText = "Please select..." };
foreach (string enumValue in (Enum.GetNames(propertyDescriptor.PropertyType)))
comboBox.Items.Add(new ListItem(enumValue, enumValue));
propertyGridParameter.Editor.Add(comboBox);
}
propertyGridParameters.Add(propertyGridParameter);
}
prgProperties.SetSource(propertyGridParameters);
}
I'm using the latest version, v0.8.1.2802. I can create the same PropertyGridParameter in markup, no problem, but not in code-behind. Is this a known issue?Thanks,
Tim