Windows Forms Designer Sample VB.NET

   Minimize

Imports NBarcode.Writing.WindowsForms
Imports NBarcode.Interfaces
Public Class BarcodeBuilder

    Private Sub BarcodeBuilder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.PropertyGrid1.SelectedObject = Me.BarcodeWinControl1.BarcodeStyle
        Me.txtBarcodeCode.Text = Me.BarcodeWinControl1.Code
        Dim barcodeTypeNames As String()
        barcodeTypeNames = System.Enum.GetNames(GetType(BarcodeTypeEnum))
        Me.cmbBarcodeType.Items.Add("...")
        Me.cmbBarcodeType.Items.AddRange(barcodeTypeNames)
        Me.cmbBarcodeType.SelectedIndex = Array.IndexOf(barcodeTypeNames, BarcodeWinControl1.BarcodeType.Value.ToString()) + 1
        Me.Invalidate(True)

    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim dialog As New SaveFileDialog()
        If dialog.ShowDialog() = Windows.Forms.DialogResult.OK And dialog.FileName <> Nothing Then
            Me.BarcodeWinControl1.Barcode.SaveToXml(dialog.FileName)
        End If
        Me.Close()
    End Sub

    Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click
      
        If cmbBarcodeType.SelectedItem <> Nothing Then

            Dim btype As BarcodeType = BarcodeType.FromString(CStr(Me.cmbBarcodeType.SelectedItem))
            If (btype.IsUnknown <> True) Then
                Me.BarcodeWinControl1.BarcodeType = btype
            End If

        End If
        Me.BarcodeWinControl1.Code = txtBarcodeCode.Text
        Me.Invalidate(True)

    End Sub

    Private Sub cmbBarcodeType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBarcodeType.SelectedIndexChanged
      
        If (cmbBarcodeType.SelectedItem <> Nothing) Then
            Dim barcodetype As BarcodeType
            barcodetype = barcodetype.FromString(CStr(Me.cmbBarcodeType.SelectedItem))
            If barcodetype.IsUnknown() <> True Then
                Me.BarcodeWinControl1.BarcodeType = barcodetype
                Me.Invalidate(Me.BarcodeWinControl1.Region)
            End If

        End If


    End Sub

    Private Sub PropertyGrid1_PropertyValueChanged(ByVal s As System.Object, ByVal e As System.Windows.Forms.PropertyValueChangedEventArgs) Handles PropertyGrid1.PropertyValueChanged
        System.Diagnostics.Debug.WriteLine(s.ToString())
        Me.Invalidate(True)
    End Sub
End Class