上篇很偷懶的寫了自動格式設置.
把沒講完的補上.
一.智能標記
先看一張圖.

GridView右側的小三角可以很輕松的幫助我們設置常用的屬性,如下面的啟動分頁,啟用排序等,通過這樣的方式我們可以很快的完成工作。我們稱這樣的任務菜單為智能標記.
下面來看看如何實現
1.重寫ControlDesigner的ActionLists屬性
你必須重寫這個屬性,返回你自定義的智能標記集合(即DesignerActionListCollection),這裡假設CustomControlActionList為自定義的智能
public class SampleControlDesigner : ControlDesigner
{
public SampleControlDesigner()
: base()
{
}
//創建一個自定義操作列表集合
public override DesignerActionListCollection ActionLists
{
get
{
DesignerActionListCollection actionLists = new DesignerActionListCollection();
actionLists.Add(new CustomControlActionList(this));
return actionLists;
}
}
}