Hide properties in PropertyGrid

  • Thread starter Thread starter rt
  • Start date Start date
R

rt

Hello,

I need to be able to hide properties for an object that is contained in
another object. In other words, Class A has many items of type Class B. I
cannot change Class A to use a derived Class B in which case I could use
ICustomTypeDescriptor. Is there another way to filter properties?

Thanks,

Rick
 
Is this what you are looking for?

===== Assembly1.DLL ============================
public class A
{
...
public class B //Class B can be declared
// inside or outside of A with same effect.
{
...
public string Prop1{get;set;} //visible anywhere
internal string Prop2{get;set;} //visible only in "Assembly1" -
// class A, B, and C, but not D
}
}
public class C{...} //could change B.Prop1 and B.Prop2
=============================================
===== Assembly2.DLL ============================
//references Assembly1.DLL
public class D{...} //cannot change B.Prop2, but can B.Prop1
=============================================

Since you control all of Assembly1, you can exert self control to prevent
changing B.Prop2 from class C.
 
Michael,

Thanks for the reply. I don't think this will work unless I'm missing what
you have shown. Classes A and B are third party and the only thing I can do
is reference the assembly in which they are contained.

Thanks,

Rick
 
Michael,

I have a third party grid. The properties I'm after are cells in the grid.
Say the grid is TGrid and the cells are TCell. I'm simply setting the
PropertyGrid.SelectedObject equal to one of the cells in the grid. I cannot
make TGrid use a new class derived from TCell. I could create a new class
that has properties I want exposed and when the cell is selected use an
instance of that class to update the "real cell". Yuck! There are a number
of custom property editors that TCell uses and I would need to handle that
as well. I was hopeful that PropertyGrid would have some callback mechanism
to ask "Do you want to show property 'abc'" but I don't see anything like
that.

Thanks,

Rick
 
Back
Top