Hello... I've been using the ultragrid v6.2 in an application for a while with no problems... I recently needed to use the UltraFormattedTextEditor from v8.3, so I went ahead and swapped everything over to v8.3. programmatically everything is fine but I immediately noticed the first column in one of my grids is way too wide and it can't be resized to be any smaller. This grid is bound to a BindingList(of Customer), as are all the grids in my app (bound to a BindingList). The only thing different about this grid is that some of the customers have a subcollection of additional customers. The code I'm using to bind is as follows:
Me.cboCustomers.Items.Add("")For Each cust As Customer In _customers.Values custClone = DirectCast(cust.Clone, Customer) _customerGridCollection.Add(custClone) Me.cboCustomers.Items.Add(custClone)NextugCustomers.DataSource = _customerGridCollection
I've got code to go through and do a PerformAutoResize on the main band and immediately after that, the column width in question shows 110 in the debugger, but still shows up at LEAST 600px wide in the grid. It does this regardless of if I run the performautoresize code.
If I make the subcollection of customers not browsable in the grid it looks good, but I need the subcollections visible. When looking at the bands collection it now has 391 bands instead of three that were in the list before the 8.3 upgrade.
Any ideas on what I can do to get around this?
Interesting... that makes sense... I was wondering if it had something to do with the 391 bands! Just to confirm it was caused by the 8.3 upgrade, I went through and removed all 8.3 references and replaced them with 6.2 references (as I decided against using the UltraFormattedTextEditor in favor of an UltraFormattedLinkLabel, so no need for 8.3)... and magically, it was ok again. So there's definitely something about 6.2 that's different.
Either way, I'll try this when I switch back to 8.3. The AllowColSizing property will help me in other ways as well.
Thanks!
Hi,
DamnRock said:Any ideas on what I can do to get around this?
Yes, I have a pretty good idea why this is happening and how to fix it. The only puzzling thing here is why this didn't happen in the old version. :)
By default, the grid column widths are synchronized across every band. Since each band is indented a little, the first column in the root-level band has to be big enough to accomodate the right-most edge of the first column in the lowest-level band.
In this case, you are binding the grid to a data source that is recursive, so there are essentially an infinite number of bands.
There's a property on the DisplayLayout called MaxBandDepth which defaults to 100 to prevent infinite recursion. But 100 is still pretty huge. So one thing you can do is set this property to a more reasonably number. Somewhere between 5 and 8 generally works best in my experience.
Another thing you could do is set AllowColSizing to Free. This allows each band in the grid to have column widths that are independent of the other bands.