Zum Hauptinhalt gehen



'Left justifying' a row of conditional elements?


2 Kommentare

  • Avatar
    Xabier Clemente

    Hello Troy,

    Thank you for reaching us via our Community Forums.

    Unfortunately, in BarTender Designer it is not possible to directly left justify conditional items on a layer and have the space collapse to the left when an item is not included on a label. However, you can achieve a similar effect by using conditional formatting and scripting.

    Here's a general approach you can follow:

    1. Place all the conditional items on the layer, aligned to the left.

    2. Set the visibility of each item based on the conditions using conditional formatting. This means that when an item is not included on a label, it will be hidden.

    3. To collapse the space to the left when an item is hidden, you'll need to use scripting. BarTender supports VBScript, and you can utilize it to manipulate the positions of the objects dynamically.

    Here's an example script that demonstrates how you can achieve the collapsing effect:

    Sub OnPostPrompt

        Dim leftPosition As Integer
        Dim gapSize As Integer
        Dim i As Integer

        ' Set the initial left position and gap size
        leftPosition = 100 ' adjust as needed
        gapSize = 10 ' adjust as needed

        ' Loop through the conditional objects on the layer
        For i = 1 To Format.Objects.Count
            ' Check if the object is visible
            If Format.Objects.Item(i).Visible = True Then
                ' Set the position of the visible object
                Format.Objects.Item(i).Left = leftPosition
                ' Update the left position for the next object
                leftPosition = leftPosition + Format.Objects.Item(i).Width + gapSize
            End If

    End Sub

    In this script, you need to adjust the initial leftPosition and gapSize values according to your specific layout requirements. The script iterates through each object on the layer and checks if it's visible. If an object is visible, its left position is set to leftPosition, and leftPosition is updated to include the object's width and the desired gap size.

    By utilizing conditional formatting and the provided script, you should be able to achieve the effect of left justifying conditional items and collapsing the space to the left when an item is not included on the label. However, please remember you will have to modify the script and layout settings to fit your specific needs.

    I hope this helps!

  • Avatar
    Peter Thane

    Not sure if something simpler could work here, rather than VB, just use multiple substrings and so the if the first string is empty the 2nd string would automatically move across to the left, as per the image below:




Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.