all groups > dotnet windows forms designtime > july 2005 >
You're in the

dotnet windows forms designtime

group:

Readonly CollectionEditor?


Readonly CollectionEditor? webcliff NO[at]SPAM gmail.com
7/11/2005 8:11:38 AM
dotnet windows forms designtime:
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
Re: Readonly CollectionEditor? webcliff NO[at]SPAM yahoo.com
7/11/2005 11:23:22 AM
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.
AddThis Social Bookmark Button