We are currently using the Xceed PropertyGrid
control to display our application's printing settings. Here is an excerpt from the class we are using:
public class ReportOptions {
public FontOptions FontOptions { get; } = new FontOptions();
public PageOptions PageOptions { get; } = new PageOptions();
}
[ExpandableObject]
public class FontOptions {
public string FontName { get; set; } = "Times New Roman";
public double HeadingFontSize { get; set; } = 14.0;
public double BodyFontSize { get; set; } = 12.0;
}
[ExpandableObject]
public class PageOptions{
[ExpandableObject]
public Thickness Margins { get; set; } = new Thickness(0.5, 1.0, 0.5, 1.0);
[ExpandableObject]
public Size Size { get; set; } = new Size(8.5,11.0);
}
The issue we are having is the Size
class has a read-only IsEmpty
property which we would like to hide in the PropertyGrid
.
Since we are using the auto-generated properties for the grid, and since we don't 'own' the Size
class, we're not sure how to decorate that property to hide it.
We tried using PreparePropertyItem
but the PropertyItem.IsVisible
is read-only.
So how can we hide that property without having to manually define all properties? (Again, this is just a small excerpt of the actual class.
You need the Browsable(false) attribute to hide something from the PropertyGrid. If you need to set the attribute at runtime, you may want to look into something like DynamicTypeDescriptor
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.