属性更改不会在设计视图中刷新用户控件 [英] Property change doesn't refresh user control in design view

查看:86
本文介绍了属性更改不会在设计视图中刷新用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个用户控件,其中我已经在其中放置了一个按钮。我已经向该用户控件添加了一个属性"TEXT"。当我在属性窗口中更改此控件的属性时,它应该更改按钮文本,但更改不会反映在用户控件的设计视图中。我在属性的set方法中添加了Refersh()以及Invalidate()但仍然没有更改可以看出。

需要做些什么才能解决问题

感谢adavce。

Hi,
I have created a user control wherein I have placed a button in it.I have added a property say TEXT to this user control.When i change the property of this control in the property window ,it should change the button text,but the change doesn't get reflected in the design view of the user control.I added the Refersh() as well as Invalidate() in the set method of the property ...but still no changes could be seen.

What needs to be done to get the issue resolved

Thanks in adavce.

推荐答案

在setter上调用Invalidate()实际上应该足够好了。对于像Text这样的内置属性,我会覆盖OnTextChanged事件,并在调用base之后添加对Invalidate()的调用。
Calling Invalidate() on the setter should actually be good enough. For built in properties like for instance Text, I would override the OnTextChanged event and add a call to Invalidate() after calling base.


这篇关于属性更改不会在设计视图中刷新用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆