PDA

View Full Version : making labels evenly sized


Jeroen
2009-04-15, 22:49
I was wondering if there's a way of doing the following.

Say I have a label with numeric values, like ListItem.Episode
Is there a way to automatically fill in a leading zero so it always displays with two digits so when used in a list I get a nice even column of information?

Rocky5
2009-04-15, 23:12
I was wondering if there's a way of doing the following.

Say I have a label with numeric values, like ListItem.Episode
Is there a way to automatically fill in a leading zero so it always displays with two digits so when used in a list I get a nice even column of information?

<align>left</align> or <align>center</align> or <align>right</align>

this will align the text to that position.

not sure if you can do this <label>00 +or| $info[ListItem.Episode]</label> or something like this.

jmarshall
2009-04-16, 03:31
Other than aligning right, that's a no, yeah.

skunkm0nkee
2009-04-16, 19:06
You might be able to do something with conditional includes and the string functions.



<includes>
<include name="PadWithZero">
<label>$INFO[ListItem.Episode,0]</label>
</include>

<include name="DontPadWithZero">
<info>ListItem.Episode</info>
</include>
</includes>

....



<control type="label">
<include condition="[[substring(ListItem.Episode,1,Left) + !stringcompare(ListItem.Episode,1)] | [substring(ListItem.Episode,2,Left) + !stringcompare(ListItem.Episode,2)]]">DontPadWithZero</include>
<include condition="![[substring(ListItem.Episode,1,Left) + !stringcompare(ListItem.Episode,1)] | [substring(ListItem.Episode,2,Left) + !stringcompare(ListItem.Episode,2)]]">PadWithZero</include>
</control>


I've not tested it so it may not work but something along those lines could work? (The above will only work with up to 29 episodes but you can easily expand it to handle more)

It's not pretty but it might work

skunkm0nkee
2009-04-16, 19:11
Actually now I think about it, it would probably be better to just have 2 labels and use the conditions above as visibility conditions. (Include conditions will only fire when the page loads)

Jeroen
2009-04-16, 20:11
Smart thinking skunk, definitely going to try that out tonight :) Thanks all

jmarshall
2009-04-18, 01:02
Nice idea. Remember to check your font has constant width for each number ofcourse :)