我嘗試打印選定的索引項目,但我無法成功。打印選定的索引項目
你能幫我解決這個問題嗎?
我在打印的頁面上得到「-1」值。
Private Sub Textbox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
Dim idx As Integer = ListBox1.FindStringExact(TextBox2.Text)
If idx <> -1 Then
ListBox1.SelectedIndex = idx
ListBox2.Items.Add(ListBox1.Text)
ListBox1.Items.Remove(TextBox2.Text)
PrintDoc.Print()
End sub
Private Sub PrintDoc_PrintPage(ByVal sender As System.Object, ByVal e As Printing.PrintPageEventArgs) Handles PrintDoc.PrintPage
Dim drawfont As New Font("arial", 16)
Dim drawbrush As New SolidBrush(Color.Black)
e.Graphics.DrawString(ListBox1.SelectedIndex, drawfont, drawbrush, 100, 100)
End Sub
你得到任何錯誤?什麼意思是「沒有成功」? – hering
發生了什麼事?應該發生什麼?打印頁面上的 –
打印值顯示爲「-1」。 – bpece