Let's say I have these 4 classes:
class A {
int i;
}
class B {
int i;
bool b;
}
class C {
int i;
enum e;
}
class D {
int i;
float f;
}
I want to show class properties in a datagrid. Something like that:
+----+------+---+---+-------+-----+
| id | type | i | b | e | f |
+----+------+---+---+-------+-----+
| 1 | A | 1 | | | |
| 2 | C | 3 | | Enum1 | |
| 3 | A | 4 | | | |
| 4 | D | 1 | | | 2.5 |
+----+------+---+---+-------+-----+
The cells of the "type" column must be a drop-down menu, so the type can be switched to another type.
What is a good design pattern to solve this problem?
Of course, I had some ideas (but I don’t know which is better): Derive A, B, C and D from superclass S? Create an enum 'Type' with TypeA, TypeB, TypeC, TypeD in S, so can I use this for a column type?
, , :
E I. A, B, C D I. E "", , enum, .
"type" , ?
?