gpt4 book ai didi

c# - 隐藏可扩展属性的省略号 (...) 按钮,例如属性网格中字体属性的 "…"按钮

转载 作者:行者123 更新时间:2023-12-02 05:27:50 26 4
gpt4 key购买 nike

我在自定义控件中添加了一个新属性作为可扩展属性,例如属性网格中的字体属性。在 Windows 窗体应用程序项目中使用我的自定义控件后,我在属性网格中看到一个省略号 (…) 按钮,如字体属性的“…”按钮。 (更多信息请看下图)

One of my custom control properties

现在,我想隐藏新的可扩展属性的省略号 (...) 按钮。

可扩展的属性代码是:

[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);
}
}

最佳答案

您应该实现自己的派生自 UITypeEditor 的类并覆盖 GetEditStyle方法如下:

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.None;
}

然后使用EditorAttribute :

[Editor(typeof(YourTypeEditor), typeof(UITypeEditor))]

更新 1:

嗯。我刚刚意识到您已经在属性上应用了 EditorAttribute:

[Editor(typeof(ItemsCollectionEditor), typeof(UITypeEditor))]
public SimilarFloorsInformation SimilarFloorsInfo
{
get
{
return similarFloorsInformation;
}
}

所以你应该覆盖 ItemsCollectionEditor 中的 GetEditStyle

关于c# - 隐藏可扩展属性的省略号 (...) 按钮,例如属性网格中字体属性的 "…"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12826684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com