public override UITypeEditorEditStyle GetEditStyle( ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (value != null)
ofd.FileName = value.ToString();
ofd.InitialDirectory = "D:\\data\\新建文件夹";
//ofd.Filter = "All Files|*.*";
ofd.Title = "选择文件";
ofd.StartPosition = FormStartPosition.CenterParent;
if (ofd.ShowDialog() == DialogResult.OK)
{
return ofd.FileName;
}
return base.EditValue(context, provider, value);
}
我对一个属性应用了上面的attribute
System.ComponentModel.Editor(typeof(FilteredFileNameEditor),typeof(System.Drawing.Design.UITypeEditor))]
public string UgInputModelPath{get;set;}
功能上没问题,但是编辑框依然是可以编辑的,虽然可以用readonly 的attribute限制用户编辑,但是编辑框看起来依然是可以编辑(实际编辑不了),有没有办法让这个编辑框看上去就不可编辑呢(只能点击后面的...按钮来弹出文件选择对话框)?
--
修改:moneybox FROM 106.39.42.*
FROM 106.39.42.*