Context:
I have a list with indeterminately entrys @design time. The user
should choose one of the item via property grid.
I create a classes and a instances of enums @RunTime. For each
needed/created enum a property spec will be defined - which will feed
a PropertyBag.
Problem:
My Problem is that the PropertyGrid wont display a DropDown Menu for a
new created Instance but give me an exception.
Question
I think the property grid can handle simple datatypes like enum - that
it does for enums defined @design time. so why not here
if the solution isn't that simple - some code would be nice.
Danke, Denis
Code for fill one GridEntry:
#region #region note all allowed values
ArrayList EnumMembers = new ArrayList();
int ValueIndex = 1;
int loopIndex = 0;
foreach(SchemaString loopString in
currentDefinition.GetTypeDefinitionAt(DatasetEntry Index).AllowdSequeces.MyEntrys)
{
loopIndex++;
if (loopEntry.Value == loopString.Value) ValueIndex =
loopIndex;
EnumMembers.Add(loopString.Value);
}
#endregion
#region type factory
//create class factory
ClassFactory enumClassCreator = new
ClassFactory(AppDomain.CurrentDomain , GetType().Assembly.FullName);
//create class
Type newEnumClass = enumClassCreator.CreateEnum(this, TagName ,
(string[])EnumMembers.ToArray(TagName.GetType()));
//instanciate class
Enum newEnumInstane =
ClassFactory.CreateEnumInstance(newEnumClass);
ClassFactory.SetEnumValue(newEnumInstane , ValueIndex);
#endregion
#region setup property specification
//create new specification
ps = new PropertySpec (TagName , newEnumInstane.GetType(),
TagCategory , TagDescription);
//source
ps.SourceInstance = (Enum)newEnumInstane;
ps.SourceType = newEnumClass;
//Target
ps.TargetFunction =
CurrentDataset.GetType().GetMethod("ReplaceEntryAt ");
ps.TargetFunctionParameters = new object[2]{null ,
DatasetEntryCount};
ps.TargetFunctionParameterIndex = 0;
ps.TargetFunctionParameterType = typeof(string);
#endregion
bag.Properties.Add(ps);