Linq over entities DataGridView - no Display

kkemerait

Member
Joined
Aug 30, 2008
Messages
10
Location
Underhill, VT
Programming Experience
10+
Using a Linq statement to select objects from a custom collection
Code:
Private Items As New Generic.List(Of T)
.

The funtion is as follows...

Code:
Public Function AllChildren() As Generic.IEnumerable(Of T)
        Dim Query = From Child As T In Items Select Child
        Return Query.ToList
    End Function
The "Query" returns to the winform correcly populated with 5 rows and two columns per row ... however... when I bind it to a grid ....

Code:
Datagridview1.DataSource = MyUser.Queues.AllChildren
no data displays (it works fine when bound to a combobox however)

if I add a column manually to the grid .. I can see there are 5 rows after binding but still no data displayed .... thoughts?
 

kkemerait

Member
Joined
Aug 30, 2008
Messages
10
Location
Underhill, VT
Programming Experience
10+
They do indeed :)

yes class instances .... they have public properties ... here's a sample of the one one in question (btw it works fine when bound to a combobox)

Code:
Friend Class Queue
    Implements VTW.Emprise.Interface.iQueue

    Private mID As Guid
    Private TicketManager As Manager(Of iTicket) = Factory.Create(Of iTicket)()
    Private TaskManager As Manager(Of iTask) = Factory.Create(Of iTask)()

    Public Sub New()
        mID = System.Guid.NewGuid
    End Sub

    Public ReadOnly Property ID() As Guid Implements [Interface].iQueue.ID
        Get
            Return mID
        End Get
    End Property

    Public ReadOnly Property IDName() As String Implements [Interface].iChildren.IDName
        Get
            Return mID.ToString
        End Get
    End Property
End Class
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,324
Location
Norway
Programming Experience
10+
Well, I just ran your Queue class through the AllChildren method binding it to DataSource of a fresh DataGridView, and I see no problem with it.
 

kkemerait

Member
Joined
Aug 30, 2008
Messages
10
Location
Underhill, VT
Programming Experience
10+
The Problem was....

Queue implements iQueue which inherits from iChildren. If the property is declared in iChildren and the object is typed as iQueue in the collection bound to the grid, the grid doesn't see the property even though it is accessible if you simply retrieve an instance of the class and use the iQueue interface. The combobox seems to find it as well ... once i moved the property to iQueue the problem vanished.

Public Interface iChildren
ReadOnly Property Animal() As String
End Interface

Public Interface iQueue
Inherits iChildren
End Interface

Public Class Queue
Implements iQueue
...
End Class

Grid will not see "animal" if Queue is typed as iQueue

I am not sure that I understand the behavior but at least now I can work around it (I hope!) ....

Thanks for the Help
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,324
Location
Norway
Programming Experience
10+
I wrongly assumed you had a List(Of Queue) since you presented the Queue class and said it didn't display data. I don't know why inherited interface properties aren't included, inherited class properties are. What I also don't understand is you say "no data displays" when using the List(Of iQueue) where your object implementation Queue "Implements iQueue.ID", so you should see ID.
 
Top Bottom