Hi,
maybe this is an easy task but I couldn't solve it. til now
I've an object that is bound to a WinGrid using a BindingSource. This object has some properties like strings etc. and a property with a list (System.Collections.Generic.List<T>) containing objects of another class. This list is shown in the VS Designer as an extra band.
Since I'm only interested in showing some of the properties of the 'main' band and not the additional band I set this to hidden which works pretty fine but the property still gets accessed although it's data is not presented. The problem is that this property uses lazy initialization, fetching the data from the database which is unnecessary because it's not getting displayed at all.
My question is can I disable an entire band or is there another possibility to overcome accessing the property?
Thanks in advance, Wolfgang
Hi Wolfgang,
qbupoew said:Although I can understand that you don't want to change the actual behaviour since it could break existing applications but on the other hand it makes things not very obvious and maybe there will be other customers complaining on that but it is your decision if you treat that as a bug or not.
I agree with you. The problem is that some application out there could be referencing the child band in code even though it's not displayed in the grid. If we changed this, that application would suddenly start blowing up because the child band won't be there any more.
It would be great if we could change it and you are right that it would alleviate some confusion. But I just don't think it's worth the risk in this case.
Hi Mike,
I approved your good news by setting MaxBandDepth and it works both in the Test Application I've sent you in my last posting and in my real application - thanks for that.
Although I can understand that you don't want to change the actual behaviour since it could break existing applications but on the other hand it makes things not very obvious and maybe there will be other customers complaining on that but it is your decision if you treat that as a bug or not.
Kind regards, Wolfgang
Hi WolfGang,
It appears that the grid doesn't look at the Hidden property on the band, nor the ViewStyle property when determining whether or not to get the child bands. This might be a bug, but it's probably not something we want to change at this point, since it could break existing applications.
The good news is that the grid does look at the MaxBandDepth. So if you set MaxBandDepth to 1, it will solve the problem in this test application.
sorry about the confusion concerning the two grids. They are not bound to the same data source and all that I wanted to say is that the event is fired from another grid. Anyhow, it has nothing to do with the real problem.
I've prepared a very simple project that demonstrates it.
It consists of a simple class 'User' that has the properties 'FirstName' and 'LastName' that are of type 'string'. It has also a property 'Roles' that is of type 'List<string>'. I've created a binding source out of class 'User', bound it to a WinGrid and got 2 bands, one for the 'User' object and another for the 'Roles'. I set the ViewStyle in DisplayLayout to SingleBand so the 'Roles' are not displayed yet if I set a breakpoint on the 'Roles' getter it is being called. This is exactly the same behaviour I'm experiencing in my 'real' application.
Although I hope you can easily work with that sample here is the callstack with more details from the breakpoint:
I hope that uploading of the ZIP-File worked. If you need any further assistance don't hesitate to contact me again.
I don't see any code in your call stack that references the WinGrid. Maybe that's the "[External Code]". I think maybe there is a way in Visual Studio to turn on the display of the external code so you can see what's happening. there. Maybe on the context menu in the Call Stack Window?
qbupoew said:Important to say is that the UltraGrid sending the event is not the UltraGrid where I'm newly setting the binding!
I'm a little confused by this. You have more than one grid bound to the same data source?