Files
wg_cpso/CaeKnowledge/View/FileNameEditor.cs

26 lines
739 B
C#
Raw Normal View History

2026-03-25 18:20:24 +08:00
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
namespace CaeKnowledge.View
{
public class FileNameEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
using (var dlg = new OpenFileDialog())
{
dlg.FileName = value as string;
if (dlg.ShowDialog() == DialogResult.OK)
return dlg.FileName;
}
return value;
}
}
}