Results 1 to 1 of 1

Thread: DataGridViews bound to nested BindingList(Of T); Get-Property-loop

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    185

    DataGridViews bound to nested BindingList(Of T); Get-Property-loop

    Hi,
    I seem to have some looping problem, where the program constantly requests the name property for a specific object, that is bound to a DataGridView, as a BindingList(Of T1). The thing is I have a nested structure of objects where each T has an object that is BindingList(Of T+1). Down to 3 levels, and each object (T1 to T3) is bound to it's own DataGridView.

    The loop is only observed (but may exist otherwise) when I click "Break All" in debugging mode, then it's unable to come to rest while I'm clicking "Step Into"[F8]. It repeatedly goes to one of the T1-T3 Get Name Property, for as many times there are elements, then returns to form, and goes right back to request the same property again. The structure looks like this:

    Code:
    Public Class T
       Private _t1s as New BindingList(Of T1)
    
       Public Property T1s as New BindingList(Of T1)
         Get
           Return Me._t1s
         End Get
         Set... 
    
    Public Class T1
       Private _name as String
       Private _t2s as BindingList(Of T2)
    
       Public Property Name as String
          Get
             Return Me._name
          ...
    
       Public Property T2s as New BindingList(Of T2)
         Get
           Return Me._t2s
         ...
    
    Public Class T2 
       Private _name as String
       Private _t3s as BindingList(Of T3)
    
       Public Property Name as String
          Get
             Return Me._name
          ...
    
       Public Property T3s as New BindingList(Of T3)
         Get
           Return Me._t3s
         ...
    
    Public Class T3
       Private _name as String
       Public Property Name as String
          Get
             Return Me._name
          ...
    Code:
    Public Class Form1
       private _t as New T
       Public Sub Form1_Load(....
          Me.DataGridView1.DataSource = _t.T1s
          ...
       
       Public Sub DataGridView1_CellClick(....
          Dim selectedT1 as T1 = _t.T1s(Me.DataGridView1.CurrentRow.Index)
          Me.DataGridView2.DataSource = selectedT1.T2s
     
       Public Sub DataGridView2_CellClick(....
          Dim selectedT1 as T1 = _t.T1s(Me.DataGridView1.CurrentRow.Index)
          Dim selectedT2 as T2 = selectedT1.T2s(Me.DataGridView2.CurrentRow.Index)      
          Me.DataGridView3.DataSource = selectedT2.T3s
    So ??.. Am I making a mistake by making the next level object a property? Is this what causes the loop? If so, how to solve it? Hopefully you will be able to spot my mistake..

    Also the debugging doesn't allow me to see what's happening, as it just jumps straight into the Get Name property method. Is there some preference to switch on such that I can see what type of hidden EventArgs classes the debugging goes through? That is, if that's a good way to find the cause ? I don't know..

    EDIT: The loop seems not always to be on T1 name property. Sometimes it loops only on T1, sometimes it runs through T3, T2, T1.. or sometimes only T3.. Not sure why. The point is, it never stops.. (while hitting F8)
    Last edited by bretddog; Apr 25th, 2010 at 10:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width