public class FileNameList : TypeConverter
{
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
if (context == null)
{
return null;
}
ArrayList fileList = new ArrayList();
string[] dirs = Directory.GetFiles(Path.Combine(Environment.Expand EnvironmentVariables("%userprofile%"), "Documents\\myFiles\\"));
string[] separatingChars = {Path.Combine(Environment.ExpandEnvironmentVariabl es("%userprofile%"), "Documents\\myFiles\\"), ".csv" };
fileList.Add("Choose");
foreach (string dir in dirs)
{
string[] words = dir.Split(separatingChars, System.StringSplitOptions.RemoveEmptyEntries);
fileList.Add(words[0]);
}
return new TypeConverter.StandardValuesCollection(fileList);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
private string sTradeFiles = "";
[GridCategory("Parameters")]
[TypeConverter(typeof(FileNameList))]
public string TradeFiles
{get;set;}
THIS WORKS GOOD
NOW LOOK A THIS
public class ResFileNameList : TypeConverter
{
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
if (context == null)
{
return null;
}
ArrayList resFileList = new ArrayList();
string[] dirs = Directory.GetFiles(Path.Combine(Environment.Expand EnvironmentVariables("%userprofile%"), "Documents\\myFiles\\"));
string[] separatingChars = {Path.Combine(Environment.ExpandEnvironmentVariabl es("%userprofile%"), "Documents\\myFiles\\"), ".csv" };
resFileList.Add("Choose");
foreach (string dir in dirs)
{
string[] words = dir.Split(separatingChars, System.StringSplitOptions.RemoveEmptyEntries);
resFileList.Add(words[0]);
}
return new TypeConverter.StandardValuesCollection(resFileList );
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
private string sResTradeFiles = "";
[GridCategory("Parameters")]
[TypeConverter(typeof(ResFileNameList))]
public string ResTradeFiles
{get;set;}
THIS doesn't work. it is doing the same thing. I initially tried a different file and I had this error so I decided to search the same files and it still doesn't work.
I created a dropdown lists of files but it just won't work if i have 2 typecasts
Comment