我在自定义控件中添加了一个新属性作为可扩展属性,例如属性网格中的字体属性。在 Windows 窗体应用程序项目中使用我的自定义控件后,我在属性网格中看到一个省略号 (...) 按钮,例如字体属性的“...”按钮。(有关更多信息,请参见下图。)
现在,我想为我的新可扩展属性隐藏省略号 (...) 按钮。
可扩展的属性代码是:
[DisplayName("Floors Information")]
[Description("Floors Informationnnnnnnnnnnnnnnn")]
[DefaultProperty("TitleText")]
[DesignerCategory("Component")]
public class FloorsInformation : DockContainerItem
{
private SimilarFloorsInformation similarFloorsInformation = new SimilarFloorsInformation();
public FloorsInformation()
{
}
[Category("Data")]
[DisplayName("Similar Floors Panel")]
[Description("Similar Floors Panellllllllllllllllllll")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(ItemsCollectionEditor), typeof(UITypeEditor))]
//[TypeConverter(typeof(ExpandableObjectConverter))]
//[TypeConverter(typeof(SimilarFloorsInformationTypeConverter))]
public SimilarFloorsInformation SimilarFloorsInfo
{
get
{
return similarFloorsInformation;
}
}
}
[DisplayName("Similar Floors Information")]
[Description("Similar Floors Informationnnnnnnnnnnnnnnn")]
[DefaultProperty("Text")]
[DesignerCategory("Component")]
[TypeConverter(typeof(SimilarFloorsInformationTypeConverter))]
//[TypeConverter(typeof(ExpandableObjectConverter))]
public class SimilarFloorsInformation : ExpandablePanel
{
private Color canvasColor = SystemColors.Control;
private eCollapseDirection collapseDirection = eCollapseDirection.LeftToRight;
private eDotNetBarStyle colorSchemeStyle = eDotNetBarStyle.StyleManagerControlled;
private DockStyle dock = DockStyle.Right;
private eTitleButtonAlignment expandButtonAlignment = eTitleButtonAlignment.Left;
private bool expanded = false;
private bool markupUsesStyleAlignment = true;
private Size size = new Size(30, 177);
public SimilarFloorsInformation()
{
}
}
public class SimilarFloorsInformationTypeConverter : ExpandableObjectConverter//TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(SimilarFloorsInformation))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(String) && value is SimilarFloorsInformation)
{
SimilarFloorsInformation similarFloorsInformation = (SimilarFloorsInformation)value;
return similarFloorsInformation.TitleText;
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
{
SimilarFloorsInformation similarFloorsInformation = new SimilarFloorsInformation();
similarFloorsInformation.TitleText = (string)value;
return similarFloorsInformation;
}
return base.ConvertFrom(context, culture, value);
}
}