[Browsable(false)] doesn't seem to be working?

Sep 14, 2010 at 6:02 PM

Hi - first off, thank so much for doing this, I really needed a property grid in my app, and this fits the bill.

Some of my objects have collections - since the editor doesn't support collections (yet), I decided to just mark the properties as


so that they wouldn't show up in the editor - but they still do?

        private ObservableCollection<RISApplication> _applications;
        public ObservableCollection<RISApplication> Applications
            get { return _applications; }
            set { _applications = value; OnPropertyChanged("Applications"); _applications.CollectionChanged += _applications_CollectionChanged; }

Sep 14, 2010 at 6:11 PM

Might have answered my own question, but looking at the source code, it seems like I needed to include the EditorBrowsable attribute as well. This was not how I expected it to work however, I thought only the Browsable(false) would do that...


        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
Sep 15, 2010 at 1:10 PM

Looking at the source code, that should work. It defaults to being shown, and then looks for the attributes (see below). Not sure why its still showing up for you. As you can see it only evaluates EditorBrowsable if it can't locate the Browsable attribute or Browsable is true.


foreach (PropertyInfo pinfo in props)
	bool isBrowsable = true;
	BrowsableAttribute b = PropertyItem.GetAttribute<BrowsableAttribute>(pinfo);
	if (null != b)
		isBrowsable = b.Browsable;
	if (isBrowsable)
		EditorBrowsableAttribute eb = PropertyItem.GetAttribute<EditorBrowsableAttribute>(pinfo);
		if (null != eb && eb.State == EditorBrowsableState.Never)
			isBrowsable = false;
	if (isBrowsable)
		bool readOnly = false;
		ReadOnlyAttribute attr = PropertyItem.GetAttribute<ReadOnlyAttribute>(pinfo);
		if (attr != null)
			readOnly = attr.IsReadOnly;

			object value = pinfo.GetValue(objItem, null);
			PropertyItem prop = new PropertyItem(objItem, value, pinfo, readOnly);
		catch { }