共同学习SPS,掌握Csgl#,FireScript孵化纪实

——基于.NET脚本解释引擎,可以用于ASP.NET,WinForm,WebServices

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
引用: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...
posted on 2006-03-15 14:53  FireReprt◇FireScript地带  阅读(397)  评论(0编辑  收藏  举报