I'm not sure if this is a bug or not, but here is the issue I am experiencing: I am binding a custom collection to a grid but for bands more than two levels deep, no columns will display.
I am using a System.Collections.ObjectModel.Collection(Of T) class. I am using it to store a simple class that looks like:
As you can see, the only interesting thing this class has is a reference to another collection that also contains Issues.
So say I have a form with a grid on it and then populate a collection with some Issue objects. The grid will correctly display the first and second bands, but for the third band, it will show no columns and no rows - although it looks like something should be there (you can see the indicators and spacing where the columns should be).
Here is the code that populates and binds the collection. There are three Issues in the collection: the first one has no children, the second one has one child, and the third one has one child that itself has a child.
This will display the grid but there are no rows or column headers (the columns collection is empty in the band) for the Root3/Child/Child row - although it looks like something is there since it shows the indicator and has the spacing for it.
The thing is that adding the Root3 issue as the first issue in the collection (with its child and the child's child) will work. It seems that the grid is just looking at the first item in the collection to determine 'how far down to go' for band displaying (but the databinding logic sort of works since it at least seems that it 'knows' something is really there).
Does anyone have any ideas on whether this is a bug or if there is a setting I could use to force the grid to determine how many bands to display? I've tried every setting I could think of. Binding to a DataSource or DataSet with a self-referencing table object bound to the grid at design-time and then populating it at run time works, but I would really like to associate the object in the collection with the grid and not have that intermediary (and I'm not quite sure how deep the collection will get - although realistically no more than five levels deep).
Thanks in advance for any pointers.
-David
Aach, sorry, I pasted the text from Word and when I hit the post button it changed the formatting on me, here is a better post:
Imports System.Collections.ObjectModel
Private _description As String
Public Property Description() As String
Get
End Get
Me._description = value
End Set
End Property
End Class
Dim issues As New System.Collections.ObjectModel.Collection(Of Issue)
Dim rootIssue As Issue
Dim childIssue As Issue
Dim child2Issue As Issue
'Root 1rootIssue = New Issue()
rootIssue.Description = "Root Issue #1"
issues.Add(rootIssue)
'Root 2
rootIssue = New Issue()
rootIssue.Description = "Root Issue #2"
'Root 2 Child 1
childIssue = New Issue()
childIssue.Description = "Root Issue #2/Child Issue #1"
rootIssue.ChildIssues.Add(childIssue)
'Root 3
rootIssue.Description = "Root Issue #3"
'Root 3 Child 1
childIssue.Description = "Root Issue #3/Child Issue #1"
'Root 3 Child 1 Child 1
child2Issue = New Issue()
child2Issue.Description = "Root Issue #3/Child Issue #1/Child Issue #1"
childIssue.ChildIssues.Add(child2Issue)
Me.UltraGrid1.DataSource = issues
Hi David,
dpalau said:The thing is that adding the Root3 issue as the first issue in the collection (with its child and the child's child) will work. It seems that the grid is just looking at the first item in the collection to determine 'how far down to go' for band displaying (but the databinding logic sort of works since it at least seems that it 'knows' something is really there).
That is possible. The grid cannot handle a non-homogenous data source. That means that every row of data needs to have the same depth of child data. So, for example, if the first row in the grid returns null for a property that returns the list of child rows, then no other row in the grid will have child data either. If the property returns an empty collection, then it's possible that the BindingManager will be unable to determine the structure of the data beyond that level, and the grid will base all levels of data on the first row and it's descendants.
You may be able to get around this by implementing ITypedList on your data lists and IEditableObject on your dta object. The former gives the BindingManager a way to determine the structure independent of the data. The latter allows it to create a dummy row and then cancel it in order to get the structure.
Another option to consider is using UltraWinTree instead of UltraWinGrid. The tree can handle non-homogenous data. BUt it lacks certain other features of the grid like filtering and summaries, so it may not work for the needs ofyour application.