8,834
社区成员
发帖
与我相关
我的任务
分享
[Description("设置X的位移量"), DefaultValue(50), Editor(typeof(UITypeEditorOffset), typeof(System.Drawing.Design.UITypeEditor))]
public int OffetX
{
get{return this._OffsetX;}
set {
this._OffsetX = value;
this.Refresh();
}
}
public class UITypeEditorOffset : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.DropDown;
}
return base.GetEditStyle(context);
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService iService = null
if (context != null && context.Instance != null && provider != null)
{
iService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (iService != null)
{
System.Windows.Forms.TrackBar trkOffset = new System.Windows.Forms.TrackBar();
// 在这里如何初始化 trkOffset 的 Value 属性呢? 也就是说如何将上面的 OffetX 传递过来呢?
trkOffset.ValueChanged += new System.EventHandler(this.trkOffset_ValueChanged);
iService.DropDownControl(trk);
// 如何让 trkOffset 在滑块滑动时就返回值呢?
}
}
return value;
}
private void trkOffset_ValueChanged(Object sender, System.EventArgs e)
{
// ..........
}
}