关于DesignerHost属性设置

引用: http://dotnet247.com/247reference/msgs/9/47826.aspx
I'm not sure why you can't modify the Text, but the Name property hasn't
been set up by the container yet in the process of adding so the
DesignerHost is probably just over-writing your value. You'd probably be
better trying to handle that rename in OnCompoentAdded.

IComponentChangeService is how you notify that a object has been changed.
Undo/redo relies on this, as does serialization. Say you were going to
change the Text property.

IComponentChangeService changeSvc =
(IComponentChangeService)GetService(typeof(IComponentChangeService));

try {
PropertyDescriptor prop =
TypeDescriptor.GetProperties(button1)["Text"];
string oldValue = button1.Text;
changeSvc.OnComponentChanging(button1,prop);
button1.Text = "Foo";
changeSvc.OnComponentChanged(button1, prop, oldValue, button1.Text);
catch ( CheckoutException cex{
if (cex != CheckoutException.Canceled) {
throw cex;
}
}

It is very very important to balance OnComponentChanging/OnComponentChanged
calls for all actions you expect the designer to be aware of. If you need
to do multiple actions atomically, see IDesignerHost.CreateTrancaction and
DesignerTransactions.

--

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

"NAG" < Click here to reveal e-mail address> wrote in message
news:OJAqrVmrBHA.2412@tkmsftngp03...

转载于:https://www.cnblogs.com/FlyFire/archive/2006/03/15/350660.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值