I have Animal class and derived Cat class
: Class Animal
{
Public String Name{ get; set;}
}
Class Cat : Animal
Public string FurColor {get; set;}
Now I have ItemCollection<Animal> animals = new ItemCollection<Animal>(); with a few animal objects. Then I call UltraGrid1.DataSource = animals. The grid correctly shows the columns for the Animal properties.
If I populated the animal collection with a few cat objects. The grid only shows the properties of animal. No cat properties are shown as column of UltraGrid.
If I declare ItemCollection<Cat> cats and set grid data source as cats. The cat properties will be shown in the UltraGrid columns.
In WCF DataContractSerializer I can declare Cat as KnowType of Animal to get collection of anima l correctly recognized as cat. I s there a similar way for the UltraGrid to show the actual data type properties instead of only the base type.
No, I don't believe the WinGrid can support this. There are two problems with this:
I could be wrong about #2, though. And if so, you might be able to acheive what you want by using the WinTree instead of the WinGrid. The WinTree has a ViewStyle called FreeForm, in which you can display non-homogeneous data. But I think you would have to generate the ColumnSets for each possible type and assign them to the nodes yourself - probably in the InitializeDataNode event.
Hi Mike,
The user control is designed to be generic to all animals. So I declare the collection as ItemCollection<animal> _animal. But each time only one type of anumal. therefore data is homogeneous. I populated the _animal with cat objects. In debug I checked the ultraGrid DataSource, it has the right data. The grid should be smart enough to display the derived properties as its columns. There must be a way to do this.
Julie