Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Datagrid not seeing derived class

Hello all,

I am having a problem with a Datagrid not seeing the properties of a derived collection.

We have the following set up.:

Friend Class BusinessObject() {
Public ReadOnly Property IsTrue() As Boolean
  Get
    Return True
  End Get
End Property
End Class

Friend Class Bike() Inherits BusinessObject() {
Public ReadOnly Property IsBike As Boolean
  Get
    Return True
  End Get
End Property 
}

Friend Class OurCollectionBase Inherits CollectionBase {
  Public ReadOnly Property Item(index As Integer)
        As BusinessObject

      Return CType(List(index), BusinessObject)     

  End Property
}

Friend Class Bikes() Inherits OurCollectionBase { }

Then the code I am trying to run is:

Dim myBikes As New Bikes()
Dim myBike1 As New Bike()
myBikes.Add(myBike1)
Dim myBike2 As New Bike()
myBikes.Add(myBike2)

Dim dgBikeList As New DataGrid
dgBikeList.DataSource = myBikes

And what I see in the DataGrid is just the IsTrue Property. I have tried creating custom GridColumns, but even with the TableMapping set to Bikes, it will not display the IsBike() property. I can verify that the property is in the collection, but for some reason the datagrid can't see it.

Any thoughts?

CF
Tuesday, April 06, 2004

*  Recent Topics

*  Fog Creek Home