不懂,just
╭═══╮ ╭═══╮ ╭══════╮
╰╮ ╭╯ ╰╮ ╭╯ ╰╮ ╭══╮╰╮
║ ║ ║ ║ ║ ║ ╰╮╰╮
║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ╭╯╭╯
║ ║ ║ ║ ║ ╰══╯╭╯
║ ║ ║ ║ ║ ╭═══╯
║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║
╰╮╰╮ ╭╯╭╯ ║ ║
╰╮╰═╯╭╯ ╭╯ ╰╮
╰═══╯ ╰═══╯
╭═══╮ ╭═══╮ ╭══════╮
╰╮ ╭╯ ╰╮ ╭╯ ╰╮ ╭══╮╰╮
║ ║ ║ ║ ║ ║ ╰╮╰╮
║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ╭╯╭╯
║ ║ ║ ║ ║ ╰══╯╭╯
║ ║ ║ ║ ║ ╭═══╯
║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║
╰╮╰╮ ╭╯╭╯ ║ ║
╰╮╰═╯╭╯ ╭╯ ╰╮
╰═══╯ ╰═══╯
比如(下面取某个目录下文件列表):
public class FileNameConverter:StringConverter
{
public override bool GetStandardValuesSupported(
ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection
GetStandardValues(ITypeDescriptorContext context)
{
string[] strVals=null;
ArrayList stdValList = new ArrayList();
stdValList.Add("");
try
{
string path = Application.StartupPath + @"\" + DBFile.GetFilePath("Pic") + @"\" ;
path = Path.GetFullPath(path);
strVals = Directory.GetFiles(path);
for(int i = 0; i < strVals.Length ;++i)
{
string str = strVals[i];
str = Path.GetFileName(str);
stdValList.Add( str);
}
strVals = new string[stdValList.Count ];
stdValList.CopyTo(strVals);
}
catch(Exception ex)
{
}
return new StandardValuesCollection(strVals);
}
}
object obj;
PropertyDescriptor pd ; obj = context.Instance ;
pd = context.PropertyDescriptor; if (obj is PictureBox)
//do something if (pd.Name == "PointKind")
//根据属性名称做一些操作