关于ControlDesigner的一些破碎知识

[ 2007-05-20 12:31:21 | 作者: progame ]
文字大小: | |
指定designer:
[Designer(typeof(MyDataSourceDesigner))]
public class MyDataSource : SqlDataSource

添加自己的actionlist:
public override System.ComponentModel.Design.DesignerActionListCollection ActionLists
{
get
{
DesignerActionListCollection lists = new DesignerActionListCollection();
lists.AddRange(base.ActionLists);
lists.Add(new MyDataSourceDesignerActionList(this));
return lists;
}
}

添加action:
public override DesignerActionItemCollection GetSortedActionItems()
{
DesignerActionItemCollection items = new DesignerActionItemCollection();
DesignerActionMethodItem item = new DesignerActionMethodItem(this, "RetrieveDataObject", "Retrieve DataObject", "Data Action", "Retrieve DataObject from yaml", true);
item.AllowAssociate = true;
items.Add(item);
return items;
}
在DesignerActionList类中添加一个public void的method--"RetrieveDataobject"即可关联命令和执行方法

得到当前Page的Name:
IReferenceService的references中的第一个即是,当然也可以通过IDesignerHost再拿RootComponent也可(不知有masterpage时会如何)

对当前的Control赋值:
必须通过PropertyDescriptor来进行

Invoke报can't convert type .... to type ... ,type name都一样,但就是不能转换
删除C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies的缓存即可

Design time如何得到当前Website的绝对文件路径?
参考IWebApplication

一些有用的链接:
Sample ASP.NET Control Designer with Lists and Services
Simplify UI Development with Custom Designer Actions in Visual Studio
给自定义Control加上Smart Tag
Creating Custom Controls-Providing Design Time Support 1
Creating Custom Controls-Providing Design Time Support 2
评论Feed 评论Feed: /feed.asp?q=comment&id=778

这篇日志没有评论.

发表
表情图标
[smile] [confused] [cool] [cry]
[eek] [angry] [wink] [sweat]
[lol] [stun] [razz] [redface]
[rolleyes] [sad] [yes] [no]
[heart] [star] [music] [idea]
UBB代码
转换链接
表情图标
悄悄话
用户名:   密码:   (非注册用户不需要输入密码) 注册?
验证码(不区分大小写) * 请输入验证码