Hi guys,
I have a bit of a dilemma that I'm hoping you can help with. I am currently developing a program that involves binding IBindingLists to an Infragistics control called UltraWinGrid. Not sure if many of you have heard of it but if not it doesn't really matter.
The program involves creating objects of type MyClass, placing them in a bindinglist of type MyClass, and then binding this to the grid's datasource. Additionally, each object has its own bindinglist property, which will be set in the same way, therefore creating a hierarchical grid.
For example, say I had three classes: clsA, clsB and clsC. A grid might eventually look like this:
a1
|- b1
| |- c1
|
|-b2
where 'a1' has children 'b1' and 'b2', and 'b1' has a child 'c1'.
Now to create this is no big deal, simply assign all clsA objects a bindinglist(of clsB) and all clsB objects a bindinglist(of clsC). HOWEVER (drum roll!) it may not always follow a certain order so I can have a grid that could look like this:
a1
|- c1
|
|- c2
|-b1
where 'a1' has children 'c1' and 'c2', and 'c2' has a child 'b1'.
So in this case, I would assign all clsA objects a bindinglist(of clsC) and all clsB objects a bindinglist(of clsB). This is also fine, I have created a recursive function that will do this.
Now is where my problem arises. The bands in the grid might not always have the same TYPE of object in them. A grid could also look like this:
a1
|-b1
| |-c1
|
|-c2
where 'a1' has children 'b1' and 'c2', and 'b1' has a child 'c1'. This is impossible to do at the moment as I only have one bindinglist property and you can't have different types in a typed bindinglist. So I have to have more than one bindinglist, one for each type. But to make matters worse, I can theoretically have n number of types to add to a single level, therefore needing an n number of bindinglists. Additionally I can't just have an array or a collection of bindinglists as the original property and add to that, as the Infragistics binding method will bind to the objects in the array/collection, i.e. the bindinglist objects themselves, and not the objects inside these bindinglists.
So to cut a long story short, I need some way of creating extra bindinglist properties at run-time for an instance of a class. I have found quite a bit on using Reflection.Emit PropertyBuilder method but that only seems to apply to types, rather than instances. Also, I'm a bit confused as to how I would apply this to an already existing class/type.
Sorry if this has been a bit long-winded but I thought I better explain exactly what I was doing. Any help, guidance or ideas would be greatly appreciated.
Thanks,
Link664
I have a bit of a dilemma that I'm hoping you can help with. I am currently developing a program that involves binding IBindingLists to an Infragistics control called UltraWinGrid. Not sure if many of you have heard of it but if not it doesn't really matter.
The program involves creating objects of type MyClass, placing them in a bindinglist of type MyClass, and then binding this to the grid's datasource. Additionally, each object has its own bindinglist property, which will be set in the same way, therefore creating a hierarchical grid.
For example, say I had three classes: clsA, clsB and clsC. A grid might eventually look like this:
a1
|- b1
| |- c1
|
|-b2
where 'a1' has children 'b1' and 'b2', and 'b1' has a child 'c1'.
Now to create this is no big deal, simply assign all clsA objects a bindinglist(of clsB) and all clsB objects a bindinglist(of clsC). HOWEVER (drum roll!) it may not always follow a certain order so I can have a grid that could look like this:
a1
|- c1
|
|- c2
|-b1
where 'a1' has children 'c1' and 'c2', and 'c2' has a child 'b1'.
So in this case, I would assign all clsA objects a bindinglist(of clsC) and all clsB objects a bindinglist(of clsB). This is also fine, I have created a recursive function that will do this.
Now is where my problem arises. The bands in the grid might not always have the same TYPE of object in them. A grid could also look like this:
a1
|-b1
| |-c1
|
|-c2
where 'a1' has children 'b1' and 'c2', and 'b1' has a child 'c1'. This is impossible to do at the moment as I only have one bindinglist property and you can't have different types in a typed bindinglist. So I have to have more than one bindinglist, one for each type. But to make matters worse, I can theoretically have n number of types to add to a single level, therefore needing an n number of bindinglists. Additionally I can't just have an array or a collection of bindinglists as the original property and add to that, as the Infragistics binding method will bind to the objects in the array/collection, i.e. the bindinglist objects themselves, and not the objects inside these bindinglists.
So to cut a long story short, I need some way of creating extra bindinglist properties at run-time for an instance of a class. I have found quite a bit on using Reflection.Emit PropertyBuilder method but that only seems to apply to types, rather than instances. Also, I'm a bit confused as to how I would apply this to an already existing class/type.
Sorry if this has been a bit long-winded but I thought I better explain exactly what I was doing. Any help, guidance or ideas would be greatly appreciated.
Thanks,
Link664