Autosize for Column Widths

Another step forward in our continuing quest to improve what's already great – our table object. Until LL25, you had to decide which widths you'd like to reserve for your respective columns. While this works out just nice most of the time, sometimes the result is less than perfect.

Depending on the data you’re printing you get more whitespace than desireable, while causing wraps where you don’t want them. In LL25, we’ll introduce an autosize feature for column widths that is the perfect cure for this disease.

As an example, take the following customer list:

This is basically what happens if you drag and drop the three fields on the workspace. For clarity reasons I shrinked the second column just a bit. Now you might realize what’s wrong here – the “City” column is way too wide compared to especially the “Address” column which causes excessive whitespace on the one hand side and unneccessary wraps on the other.

Enter the new autosize feature. While before you would have gone ahead and adjust the column widths manually until you found a reasonable fit, you can now rely on List & Label making the perfect decision for you. Based on the actual content. Due to the nature of this feature, it requires a data provider to be able to freely move through the data, i.e. it’s supported for .NET, Delphi and C++ if you’re using the available data provider implementations.

That said it’s easy to use the new feature. Simply set the column widths to Null() to indicate you’d like to use automatic resizing:

If we leave everything at default, the result looks like this…

which is pretty cool. The available settings for autosize allow to fine tune the behavior:

Settings Purpose
Minimum Width Set the minimum width that should be used, even if the content wouldn’t require it
Maximum Width Set the maximum width that should be used, even if the content is actually wider
Weighting This setting determines the whitespace ratio, i.e. which fraction of whitespace should be added to (or – if the aggregated column widths are greater than the table width – substracted from) the optimal width

The last setting is a bit tricky here – just as an example let’s use “0” as weigthing for the first column, “2” for the second and “1” for the third. The result is then

Note how the first column just fits (i.e. weighting “0”) while the second column receives the doubled amount of whitespace compared to the third. Plenty of stuff to play around with for the experts here while most of the time the defaults will work just fine.

Related Posts

2 Comments on “Autosize for Column Widths”

  1. What are the prerequisites for the dataprovider? Should it work with delphi (bde). In my trials (using version 25) neither 0 nor null() is accepted.


Leave a Comment