gpt4 book ai didi

c# - 通过自定义控件 (.NET) 在设计时提供属性

转载 作者:太空宇宙 更新时间:2023-11-03 19:34:59 26 4
gpt4 key购买 nike

我创建了一些控件并定义了一些可以在设计时定义的属性,但只显示一个。另一个问题是,在显示的那个中,显示了表单的文本框,但我无法选择任何内容。

    [Description("Blah Blah Blah"),
Category("Data"),
DefaultValueAttribute(typeof(TextBox), null),
Browsable(true)]
//Only show this one
public TextBox textBox
{
set { txt = value;}
}


[Description("Blah blah blah again"),
Category("Data"),
DefaultValueAttribute(typeof(string), null),
Browsable(true)]
public string Mensaje
{
set { sMensaje = value; }
}

所以,我的代码有什么问题

最佳答案

您的属性缺少 setter/getter 。

// Snip attributes
public TextBox textBox
{
get { return txt; }
set { txt = value;}
}

// Snip attributes
public string Mensaje
{
get { return sMensaje; }
set { sMensaje = value; }
}

关于c# - 通过自定义控件 (.NET) 在设计时提供属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2297492/

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