111,128
社区成员
发帖
与我相关
我的任务
分享 [Editor("Design.ListControlStringCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
public List<string> Item //{ get; set; }
{
get
{return _Item; }
set
{_Item = value; }//当编辑属性完成按确定键时没有触发该函数,我该去哪里取我在属性栏里编辑好的值呢?[BrowsableAttribute(true)]
[DescriptionAttribute("图片集合")]
//下面这句声明你的自定义集合属性编辑器
[EditorAttribute(typeof(ImageEditor), typeof(UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Dictionary<string, Image> Images
{
get { return Images1; }
set { Images1 = value; }
}
然后在自定义你的编辑器
internal class ImageEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
//这里的GetImageList是你自定义的Form窗口
GetImageList rc = new GetImageList();
ImageList control = (ImageList)context.Instance;
rc.Images1 = control.Images1;
rc.ShowDialog();
value = rc.Images1;
}
return value;
}
}
大概就这样 你可以写个例子看看[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]