C#自定义设计器——文件名选择编辑器
暑期的时候用MCI封装了一个播放音乐的类,最近学习了GDI+,想着将这个类做成一个自定义的控件,那么在做的过程中有一个属性,如下:
public string FileName
{
get { return fileName; }
set { fileName = value; }
}
private string fileName;
编译之后,将它加到窗体上后,调到该控件的属性编辑框,可以看到,在杂项中有这个属性,我们可以在后面的框框中输入文件名,可是这个有点不人性化。我想能不能做成我一点某处就弹出一个文件选择框,通过谷歌上搜索了一下,查到了一个设计时特性——System.ComponentModel.Editor,实际上它就是定义好的一个类,其中一个构造函数如下: