0
我正在寫一個控制爲c#(WinForms),我有一個集合類型的屬性。如何打開在控制雙擊模式對話框#
當用戶選擇此屬性時,將顯示帶「...」的按鈕,並打開新的模式對話框。所有這些工作都很好,我已創建:
public class ItemsEditor : UITypeEditor
在這個類我重寫的EditValue方法與ShowDialog的開放模式的編輯器。正如我所說的那樣,工作很好。
但是,我想在控件的用戶雙擊它時打開此對話框。
爲此我必須繼承ControlDesigner:
public class MyControlDesigner : ControlDesigner
,並在這個類我都繼承下一個方法:
public override void DoDefaultAction()
{
string propertyName = "Items";
IServiceProvider provider = (IServiceProvider)GetService(typeof(IServiceProvider));
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(MyControl);
PropertyDescriptor property = properties[propertyName];
UITypeEditor editor = (UITypeEditor)property.GetEditor(typeof(UITypeEditor));
editor.EditValue(provider, null);
}
可以看出,我已經把一些隨機代碼,當然還有不工作。
有人可以幫我解決這個問題,以及如何打開雙擊屬性。
謝謝所有幫助
問候 博揚
對不起,請換成你的問題。這很難理解。 – Kugel 2011-01-25 03:04:08