In regards to actual printing, I simple set the DocumentName of the PrintDocument, there is of course more to do here so it actually prints.
Code:Public Class SomeDemo Private dt As DataTable = LoadDataFromSomeplace() ''' <summary> ''' Load ListBox with mocked data ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub SomeDemo_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load For Each Row As DataRow In dt.Rows CheckedListBox1.Items.Add(Row.Field(Of String)("Text")) Next End Sub ''' <summary> ''' Get checked items ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click Dim xIndex As Integer = 0 For Index As Int32 = 0 To (CheckedListBox1.Items.Count - 1) xIndex = Index If CheckedListBox1.GetItemChecked(Index) Then Dim Item = ( From T In dt.AsEnumerable Where T.Field(Of String)("Text") = CheckedListBox1.Items(xIndex).ToString Select T.Field(Of String)("DocumentName") ).First PrintDocument1.DocumentName = Item ' ' Do your printing ' End If Next End Sub Private Function LoadDataFromSomeplace() As DataTable Dim dt As New DataTable dt.Columns.AddRange(New DataColumn() _ {New DataColumn With {.ColumnName = "ID", .DataType = GetType(Int32), .AutoIncrement = True, .AutoIncrementSeed = 1, .ReadOnly = True}, New DataColumn With {.ColumnName = "Text", .DataType = GetType(String)}, New DataColumn With {.ColumnName = "DocumentName", .DataType = GetType(String)}}) dt.Rows.Add(New Object() {Nothing, "Account 1", "Your info on account 1"}) dt.Rows.Add(New Object() {Nothing, "Account 2", "Your info on account 2"}) dt.Rows.Add(New Object() {Nothing, "Account 3", "Your info on account 3"}) Return dt End Function End Class




Reply With Quote
