Why does the MaxBandDepth change after the Datasource is set? According to the documentation "MaxBandDepth....Gets or sets the max band depth. Grid will load up to MaxBandDepth number of bands. Note that you have to set the MaxBandDepth before binding the UltraGrid."
I am asking the question because I recently started using the UltraGridPrintDocument for a grid that is bound to objects that have normally have 2 bands. I set the MaxBandDepth to 1 just before I bind the grid and that works great. Right after I band the grid, the MaxBandDepth gets set to 100 automatically. This results in the UltraGridPrintDocument attempting to render the normally hidden bands and + signs appear on the print preview and first column is stretched to accommodation the child bands.
I was able to side step this by simply resetting the MaxBandDepth again right after set the Datasource of the grid, however the behavior was unexpected.
Everything is done at design time. Here is a snippet of code.
ugrd.DisplayLayout.MaxBandDepth = 1 ' Sets MaxBandDepth to 1 (this works)Console.WriteLine(ugrd.DisplayLayout.MaxBandDepth) ' outputs "1"
ugrd.DataSource = oTitanInvoicesConsole.WriteLine(ugrd.DisplayLayout.MaxBandDepth) ' outputs "100" (why did it get reset?)
ugrd.DisplayLayout.MaxBandDepth = 1 ' needed because binding sets it BACK to 100!Console.WriteLine(ugrd.DisplayLayout.MaxBandDepth) ' outputs "1"
Mike, pointed me in the right direction. During the InitializeLayout event, we pull grid layout settings from a database for easy reuse. I dug through that code and found the following line that is called just before any settings are applied:
Grid.ResetDisplayLayout() ' culprit
Removing that line left left the MaxBandDepth at 1.
So the answer to my original question was: "Because you told it to." Thanks for the help guys.
If the property is spontaneously changing when the you set the DataSource on the grid, then that's a bug. But I've never seen that happen before.
Is it possible that your code is resetting the property without realizing it? Maybe you are loading a Layout or a Preset into the grid that is setting this property?
Hello,
When are you doing this? Is it in design-time or run-time? 'MaxBandDepth' should be set in design-time, one time only. If this is not working, could you please try to attach, if possible, a small sample project, reproducing the above mentioned issue, I will be happy to take a look at it?