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:but the property still gets accessed
Can you post the call stack when the property is being accessed? The grid should not be trying to access the value of a field which represents a hidden band. That might be a bug.
In addition to what Vince suggested above, you might want to try setting the grid.DisplayLayout.ViewStyle to SingleBand and see if that helps.
Also, try setting MaxBandDepth to 1.
But even if those work, you should not have to set them.
Hi Vince and Mike,
thanks for your instant replies. I didn't try Vince's suggestion with the WinDataSource but set the ViewStyle to SingleBand since that was easier to do but the property for the second band still gets accessed!
Here ist the call stack:
Invoicing.dll!Altova.Invoicing.Invoice.Orders.get() Line 318[External Code]OrderManagement.dll!Altova.OrderManagement.DoneOrders.DoneOrders.OnOrderSelected(object sender = {Infragistics.Win.UltraWinGrid.UltraGrid}, System.EventArgs e = {System.EventArgs}) Line 554 + 0x13 bytes[External Code]OrderManagement.dll!Altova.OrderManagement.Common.OrderUserControl.SelectFirstRowInGridView(Infragistics.Win.UltraWinGrid.UltraGrid gridView = {Infragistics.Win.UltraWinGrid.UltraGrid}) Line 1222 + 0x10 bytesOrderManagement.dll!Altova.OrderManagement.DoneOrders.DoneOrders.OnFormLoad(object sender = {Altova.OrderManagement.DoneOrders.DoneOrders}, System.EventArgs e = {System.EventArgs}) Line 298 + 0xe bytes[External Code]OrderManagement.dll!Altova.OrderManagement.ModuleController.ShowView(object view = {Altova.OrderManagement.DoneOrders.DoneOrders}) Line 185 + 0x3a bytesOrderManagement.dll!Altova.OrderManagement.ModuleController.HandleDoneOrdersEvent(object sender = {Altova.OrderManagement.OrderManagementControl}, System.EventArgs e = {System.EventArgs}) Line 420 + 0xe bytes[External Code]OrderManagement.dll!Altova.OrderManagement.OrderManagementControl.OrderManagementControlTreeView_OnAfterSelect(object sender = {Infragistics.Win.UltraWinTree.UltraTree}, Infragistics.Win.UltraWinTree.SelectEventArgs e = {Infragistics.Win.UltraWinTree.SelectEventArgs}) Line 235 + 0x15 bytes[External Code]Infragistics.Practices.CompositeUI.WinForms.dll!Infragistics.Practices.CompositeUI.WinForms.IGFormShellApplication<Microsoft.Practices.CompositeUI.WorkItem,Altova.Acs.ShellForm>.Start() Line 25[External Code]Acs.exe!Altova.Acs.ShellApplication.Main() Line 40 + 0x1e bytes[External Code]
In line 554 the DataSource is bound to a new list of objects. Important to say is that the UltraGrid sending the event is not the UltraGrid where I'm newly setting the binding!
Here is the code snippet:
// Get the invoice from the database var invoices = Invoice.Get(new InvoiceCriteria {InvoiceId = _selectedOrder.InvoiceId}); // This is line 554invoiceBindingSource.DataSource = invoices;
var invoices = Invoice.Get(new InvoiceCriteria {InvoiceId = _selectedOrder.InvoiceId});
// This is line 554invoiceBindingSource.DataSource = invoices;
invoiceBindingSource is the BindingSource object used for data binding.
In line 318 of Invoice the property is being accessed. Here is the code snippet:
public List<Order> Orders{ get { if (_orders.Count == 0) _orders = Order.Get(new OrderCriteria() {InvoiceId = this.InvoiceId}); return _orders; } }
}
As you can see here is that we are using lazy initialization here to get the orders from the database. Orders are a second band that should not be displayed at all as I mentioned in my initial posting.
I don't know if this was helpful to you because you cannot see much in the call stack. If there is anything I can provide to you don't hesitate to contact me again.
Kind regards, Wolfgang