Barcode for WPF
BarCodeのカスタマイズ

The Barcode provides the necessary API to customize the appearance of the control. Users can set a definite bar height and bar direction for this purpose. Let's explore customization in detail.

Set Height of the Bars in the Barcode

To control the height of the bars in the Barcode control, the C1BarCode class provides the BarHeight property. With this, you can set the height, in inches, of the barcode's bars. However, if the bar height exceeds the height of the control, this property is ignored.

<c1:C1BarCode Name="barCode1" Text="ComponentOne@123" CodeType="Ansi39x" BarHeight="110" HorizontalAlignment="Left" Margin="134,217,0,0" VerticalAlignment="Top"/>
barCode1.Text = "ComponentOne@123";
barCode1.CodeType = C1.BarCode.CodeType.Ansi39;
// バーコードのバーの高さをインチ単位で設定します。
barCode1.BarHeight = 110;

Set the Direction of Bars in the Barcode

To control the direction of bars in the Barcode control, the C1BarCode class provides the BarDirection property that sets the directions using the BarCodeDirection enumeration.

There are four types of values for this enumeration:

BarCode Direction values Description
LeftToRight バーコードシンボルを左から右に印刷します(デフォルト)。
RightToLeft バーコードシンボルを右から左に印刷します。
BottomToTop バーコードシンボルを下から上に印刷します。
TopToBottom バーコードシンボルを上から下に印刷します。

Let's see how to set the direction of bars in barcode via code:

<c1:C1BarCode Name="barCode1"  CodeType="Code_128_B" CaptionPosition="Below" Text="ComponentOne@123" BarDirection="RightToLeft" HorizontalAlignment="Center" Height="38" Margin="0,73,0,0" VerticalAlignment="Top" Width="530"/>
barCode1.Text = "ComponentOne@123";
barCode1.CodeType = C1.BarCode.CodeType.Code_128_B;
// バーコードシンボルの印刷方向を指定します
barCode1.BarDirection = C1.BarCode.BarCodeDirection.RightToLeft;

The barcode in its default barcode direction looks like this:

Default direction in barcode snapshot

The output of the code snippet with bar direction as RightToLeft looks like this:

Barcode snapshot with RTL direction