May i know how i can set or fix my barcode picture view. When i success create the code.

  • Thread starter Thread starter htcting
  • Start date Start date
H

htcting

Guest
I face the issue is if my text too long my barcode picture will to long can someone help me take a look how i can fix my barcode picture when my text is too long thanks.

Imports System.Data.OleDb
Public Class Form4
Dim cnn As New OleDb.OleDbConnection
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=mydataX.mdb;"
RefreshData()
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 txtbarcode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbarcode.TextChanged
cnn.Open()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter

da = New OleDbDataAdapter("SELECT * FROM checker WHERE cbcid like '%" & txtbarcode.Text & "%'", cnn)
da.Fill(dt)

dgvData.DataSource = dt.DefaultView
cnn.Close()
End Sub
Private Sub RefreshData()
If Not cnn.State = ConnectionState.Open Then
'open connection
cnn.Open()
End If
Dim da As New OleDb.OleDbDataAdapter("SELECT cid, cbcid as [CBCID], " & _
"CheckerName as [CheckerName], Quantity as [StockQuantity],Unit as [Unit], Date as [Date], CompanyName as [CompanyName], CheckerDetail as [CheckerDetail]" & _
" FROM checker ORDER BY cid", cnn)
Dim dt As New DataTable
'fill data to datatable
da.Fill(dt)
Me.dgvData.DataSource = dt
Me.dgvData.Columns("cid").Visible = False
'close connection
cnn.Close()
End Sub
Private Sub dgvData_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvData.CellContentClick
Try
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.dgvData.Rows(e.RowIndex)
'textbox detecd db show on textbox
txtbarcode.Text = row.Cells("cbcid").Value.ToString
End If

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim b As Barcodes.Barcode39 = New Barcodes.Barcode39()
Dim img As Image
b.ShowString = chkShowText.Checked
b.TextFont = New Font("Times New Roman", 10, FontStyle.Regular, GraphicsUnit.Point)
img = b.GenerateBarcodeImage(PB.Width, PB.Height, txtbarcode.Text)
PB.Image = img
End Sub

Private Sub Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click
Me.txtbarcode.Text = ""
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form3.Show()
End Sub
Private Sub dgvData_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgvData.CellFormatting
Dim dgv As DataGridView = Me.dgvData
For i As Integer = 0 To dgv.Rows.Count - 1
For ColNo As Integer = 1 To 7
If Not dgv.Rows(i).Cells(ColNo).Value Is DBNull.Value Then
dgv.Rows(i).Cells(ColNo).Style.BackColor = Color.LightCyan
End If
Next
Next

For i As Integer = 0 To Me.dgvData.Rows.Count - 1
If Not IsDBNull(Me.dgvData.Rows(i).Cells(3).Value) Then
If Me.dgvData.Rows(i).Cells(3).Value = "0" Then
Me.dgvData.Rows(i).DefaultCellStyle.ForeColor = Color.Maroon
End If
Else
End If
Next
End Sub

Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click
If PrintDialog1.ShowDialog() = DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrintDocument1.Print()
End If
End Sub

Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
PrintPreviewDialog1 = New PrintPreviewDialog()
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.Show()
End Sub
End Class

Continue reading...
 
Back
Top