Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
How to _completely_ ignore a column while binding to a WinGrid?
posted

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

Parents
  • 469350
    Offline posted

    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.

Reply Children