Hello:
I am using an ORM/domain modeler (Mindscape LightSpeed, if that matters) and trying to bind a collection of entities to a WinGrid. The target grid is a single column of this entity within the collection. There are 4 rows and so 4 cells.
I am using Infragistics WinForms 13.1 with service packs installed through 4/8/2015. Visual Studio 2013 and .NET 4.0.
The ORM has rich relationships defined, so the entity I am binding has a property of a collection of OTHER entities. This collection is many thousand rows but is lazy loaded only when accessed. The trouble I am having is that the WinGrid accesses it. So my 4 row grid takes 20 seconds to display because it has to fetch all those thousands of rows when binding. The grid WORKS fine but takes terrible long to display.
I hide all but the column I care about in InitializeLayout but that's too far downstream.
What I am looking to do is provide this 4 cell grid in a timely fashion which means I need to stop the WinGrid from touching the columns I don't care about.
I am binding using a BindingList and assigning it to the WinGrid.DataSource which I guess I'm not supposed to do in nearly every case so I followed this article:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=6702
The Band has the derived Key of "BindingList`1" and my columns are properly named but the article changed nothing in the behavior I'm trying to avoid.
I also changed NewColumnLoadStyle to FALSE which didn't help.
I also followed the suggestions put forth here:
http://stackoverflow.com/questions/1180004/binding-to-bindinglistt-choose-what-to-bind
Does anyone have any suggestions to teach a WinGrid to just IGNORE a column while binding? HIDING a column is nice but isn't enough.
Thanks in advance.
Robert
Hi Robert,
The article you referenced here is not going to help you because it just hides the column, there is no way to remove it.
The grid will create all of the columns based on the DataSource you assign it. There's really no way around this directly. If the DataSource reveals the field to the grid, the grid will create a column for it. But there might be a workaround, depending on the situation.
RobertSL said:I am binding using a BindingList and assigning it to the WinGrid.DataSource which I guess I'm not supposed to do in nearly every case
I'm not sure what you mean buy this. Why shouldn't you use a BindingList<T>? BindingList<T> is a prefectly good data source for the grid. So I'm not sure where you got the impression that you should not use it. In fact, if you are using BindingList<T> and you can modify the class T, then you might have a way to get what you want. What you could do is place the [Bindable(false)] attribute on the property you want to hide. This will hide that property from all DataBinding, including the grid.
If that's not an option, then there may be another one. It sounds like the column you want to hide is a chaptered column, so not really a column, but a child band. In that case, you can set MaxBandDepth on the grid's DisplayLayout to 1. And also set the ViewStyle to SingleBand. That should prevent the grid from loading any child rows. This will affect ALL child bands, though, not just one. So if you have other child bands you want to show, then this will not be a viable solution.
Hi Mike:
Thanks for your time.
I came to that conclusion because anytime I use a WinGrid I end up hiding a majority of the available columns so that means a majority of processing time is spent on things I don't actually display. I don't know, maybe it's not actually slower it just seems a waste.
Anyway, that aside, I tried your suggestions but none of them affected the behavior.
[Bindable(false)] had no effect - the WinGrid happily touches the property and forces the lazy load. Or maybe the collection defeats someting and allows the load. I don't have visibility to either side though.
MaxBandDepth was already 1 and changing the ViewStyle to SingleBand didn't affect the behavior.
I guess I'll check out a DataGridView to see if that is more suitable. If not, I'll transform my bound collection in to another collection with only the properties I care about before binding. Seems a lot of work to display 4 cells in a grid, but it is what it is.
Thank you for your time.
I just tried decorating the child list property with the Browsable[false)] attribute and that seems to do the trick. The .NET CurrencyManager ignores such properties so as long as nothing else accesses it, the grid won't either.