c# winfrom 用户控件的属性为何无法改变,有解决办法吗?

mick55 2010-07-13 10:09:37
请教 c# winfrom 用户控件的属性为何无法改变,有解决办法吗?


我自定义了一个 用户控件 lbl(lable),他的text 被我设置为了 caption

在winfrom 中我 拖入了 lbl

1、属性中 无text 属性了;

2、我在 form_Load 代码中 执行 this.lbl.text='abc' 无异常,但是 text还是caption,无变化。
...全文
329 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mick55 2010-07-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyq11 的回复:]
[CategoryAttribute("自定义"),
DescriptionAttribute(""),
DefaultValue(true)]
public string Title
{
get{ return this.title; }
set{ this.title= value; }
}
[/Quote]
参考了上述方法,实现了
private string _text = "";
/// <summary>
/// 翻译前的字段名称
/// </summary>
[Description("翻译前的字段名称"), Category("翻译前的字段名称"), Browsable(true)]
public string text
{
set
{
_text = value.ToString() ;
this.lbl.Text = _text.ToString();
}
get { return _text.ToString(); }
}
mick55 2010-07-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyq11 的回复:]
[CategoryAttribute("自定义"),
DescriptionAttribute(""),
DefaultValue(true)]
public string Title
{
get{ return this.title; }
set{ this.title= value; }
}
[/Quote]

不是很明白,上述代码是要写在 用户控件 定义中,还是form中。希望说明详细一点。
wuyq11 2010-07-13
  • 打赏
  • 举报
回复
[CategoryAttribute("自定义"),
DescriptionAttribute(""),
DefaultValue(true)]
public string Title
{
get{ return this.title; }
set{ this.title= value; }
}

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧