来个问题大家来拍砖:How can I assign my propertyeditor to a component's property

AaronChengBJ 2006-04-01 02:52:36
In C# Code:
//*****************************************************************************************************
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Diagnostics;
using System.Windows.Forms.ComponentModel;
using System.Windows.Forms.Design;

namespace MyControlTest
{
/// <summary>
/// UserControl1
/// </summary>
public class MyControl : System.Windows.Forms.Control
{
private System.ComponentModel.Container components;
private string myfield = "";

public MyControl()
{
InitializeComponent();
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}


void InitializeComponent ()
{
this.components = new System.ComponentModel.Container ();
}

//PropertyEditor Assign
[
Category("Mycategory"),
Editor(typeof(MyEditor), typeof(UITypeEditor)),
DefaultValue("")
]
public string MyField
{
get
{
return myfield;
}
set
{
myfield = value;
}
}

}


//Define My property Editor
public class MyEditor : System.Drawing.Design.UITypeEditor
{

public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
//Show my dialog
value = "";
return value;
}

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}

}

}
//*****************************************************************************************************
In Delphi How can I do?

...
published
[EditorAttribute(typeof(MyEditor ),typeof(System.Drawing.Design.UITypeEditor)),
Description('Select your file'),category('MyCategory')]
property MyField :string read FMyField write FMyField ;
...

But it is not work well.
...全文
330 4 打赏 收藏 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
荣之梦 2006-04-17
  • 打赏
  • 举报
回复
纯支持
copico 2006-04-13
  • 打赏
  • 举报
回复
mark
mextb1860 2006-04-07
  • 打赏
  • 举报
回复
softforce 2006-04-06
  • 打赏
  • 举报
回复
But it is not your work.

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧