Hello,
Is there a way to make the CollectionEditor readonly?
Looks like CollectionEditor uses CollectionForm, and CollectionForm
includes this field:
internal virtual bool CollectionEditable { get; set; }
Anyone have any experience with that?
Thanks
webcliff
webcliff@yahoo.com - 11 Jul 2005 19:23 GMT
Looks like if you define your own CollectionEditor, override
CreateCollectionForm(), you will get a partly readonly collection
editor ( "Add" "Remove" order buttons disabled, but you can still
change items from PropertyGrid, can save your changes by clicking "OK"
button.
protected override CollectionForm CreateCollectionForm()
{
CollectionForm form = base.CreateCollectionForm();
PropertyInfo pi =
form.GetType().BaseType.GetProperty("CollectionEditable",
BindingFlags.NonPublic | BindingFlags.Instance);
if (pi != null)
{
pi.SetValue(form, false, null);
}
return form;
}
Now I need a way to programmatically make PropertyGrid readonly.