473,473 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Show Instances of dynamically created Enums Types in a Property Grid.

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);
Nov 15 '05 #1
0 1309

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Dodgshun | last post by:
I have 2 grids - one shows a list of table names in a database and when you click on a table name the other grid dynamically populates the grid with the table contents. My problem is that I cannot...
15
by: apm | last post by:
Can an enum start empty and be added to on the fly?
2
by: Colin McGuigan | last post by:
This is a translation of an ASP page to ASP.Net. First, the background: The goal is to have a grid of different settings for the application -- think something along the lines of the Property...
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
0
by: news.zen.co.uk | last post by:
Hi Guys, Using VB .NET 2003 and ASP1.1, I have a Datagrid embedded in an ASP page. In the processing of the ItemDataBound event I dynamically create a new Datagrid control within the Cell of the...
22
by: Ben Finney | last post by:
Howdy all, I've recently packaged 'enum' in PyPI. In its description, I make the claim that it creates "immutable" enumeration objects, and that the enumeration values are "constant" values. ...
3
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes....
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.