根据文本框的宽度打印文本。而文本源是数据库 [英] Print text according to the width of textboxes. And text source is database
本文介绍了根据文本框的宽度打印文本。而文本源是数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好编码员,我打印一些带有两个文本框的文本我,e txtPayAgainst和txtpayee2我的moto是根据txtbox1宽度打印文本,剩下的文本将打印到txtpayee2。
我尝试使用以下方法,但根据方案不能正常工作。请帮助我真正应用。
Public Sub Addpayee2()
' Dim names()As String = cboAccounts.Text.Split()
'如果names.Count > < span class =code-digit> 1 然后
' txtPayAgainst.Text = names( 0)
' txtpayee2.Text = names( 1 )+名称( 2 )+名称( 3 )+名称( 4 )
' 结束如果
尝试
Dim payee2 As String =
payee2 = cboAccounts.Text.ToString()
Dim g As Graphics = cboAccounts.CreateGraphics
Dim pword As String,poneLine As String
Dim ptest As String =,ptest1 As String =
Dim pwords()As String
如果g.MeasureString(payee2,cboAccounts.Font).Width> = cboAccounts。宽度然后
poneLine = payee2
pwords = poneLine.Split()
每个pword在pwords
ptest = ptest& pword
如果g.MeasureString(ptest,cboAccounts.Font).Width> = cboAccounts.Width那么
txtPayAgainst.Text = ptest1
GoTo l1
否则
ptest = ptest&
ptest1 = ptest
结束如果
下一个
l1:txtPayAgainst.Text = ptest1
txtpayee2.Text = payee2.Substring(ptest1.Length)
' txtPayAgainst.Text = payee2.Substring( 0 , 10 )
' txtpayee2.Text = payee2.Substring(10 )
' ' txtpayee2.Visible = True
Else
txtPayAgainst.Text = payee2
txtpayee2.Text =
' txtpayee2.Visible = True
End if
Catch ex As Exception
MsgBox(ex.Message ,, Check Print)
E. nd尝试
结束子
解决方案
Public Sub Addpayee2()
尝试
Dim payee2 As String =
payee2 = cboAccounts.Text.ToString()
Dim g As Graphics = cboAccounts.CreateGraphics
Dim pword As String,poneLine As String
Dim ptest As String =,ptest1 As String =
Dim pwords()As String
如果g.MeasureString(payee2,cboAccounts.Font).Width> = cboAccounts.Width那么
poneLine = payee2
pwords = poneLine.Split()
每个pword在pwords
ptest = ptest& pword
如果g.MeasureString(ptest,cboAccounts.Font).Width> = cboAccounts.Width那么
txtPayAgainst.Text = ptest1
GoTo l1
否则
ptest = ptest&
ptest1 = ptest
结束如果
下一个
l1:txtPayAgainst.Text = ptest1
txtpayee2.Visible = True
txtpayee2.Text = payee2.Substring(ptest1.Length)
'txtPayAgainst.Text = payee2.Substring(0,10)
'txtpayee2.Text = payee2.Substring(10)
''txtpayee2.Visible = True
否则
txtPayAgainst.Text = payee2
txtpayee2.Text =
txtpayee2.Visible = False
结束如果
Catch ex As Exception
MsgBox(ex.Message ,,Check Print)
End Try
End Sub
Hi coders, I am printing some text with two textboxes I,e txtPayAgainst and txtpayee2 my moto is to print text according to the txtbox1 width and remaining text will be print into txtpayee2.
I tried with below method but its not working according to the scenario. Please help I will be really appreaciated.
Public Sub Addpayee2()
'Dim names() As String = cboAccounts.Text.Split(" ")
'If names.Count > 1 Then
' txtPayAgainst.Text = names(0)
' txtpayee2.Text = names(1) + names(2) + names(3) + names(4)
'End If
Try
Dim payee2 As String = ""
payee2 = cboAccounts.Text.ToString()
Dim g As Graphics = cboAccounts.CreateGraphics
Dim pword As String, poneLine As String
Dim ptest As String = "", ptest1 As String = ""
Dim pwords() As String
If g.MeasureString(payee2, cboAccounts.Font).Width >= cboAccounts.Width Then
poneLine = payee2
pwords = poneLine.Split(" ")
For Each pword In pwords
ptest = ptest & pword
If g.MeasureString(ptest, cboAccounts.Font).Width >= cboAccounts.Width Then
txtPayAgainst.Text = ptest1
GoTo l1
Else
ptest = ptest & " "
ptest1 = ptest
End If
Next
l1: txtPayAgainst.Text = ptest1
txtpayee2.Text = payee2.Substring(ptest1.Length)
' txtPayAgainst.Text = payee2.Substring(0, 10)
' txtpayee2.Text = payee2.Substring(10)
' 'txtpayee2.Visible = True
Else
txtPayAgainst.Text = payee2
txtpayee2.Text = ""
'txtpayee2.Visible = True
End If
Catch ex As Exception
MsgBox(ex.Message, , "Cheque Print")
End Try
End Sub
解决方案
Public Sub Addpayee2() Try Dim payee2 As String = "" payee2 = cboAccounts.Text.ToString() Dim g As Graphics = cboAccounts.CreateGraphics Dim pword As String, poneLine As String Dim ptest As String = "", ptest1 As String = "" Dim pwords() As String If g.MeasureString(payee2, cboAccounts.Font).Width >= cboAccounts.Width Then poneLine = payee2 pwords = poneLine.Split(" ") For Each pword In pwords ptest = ptest & pword If g.MeasureString(ptest, cboAccounts.Font).Width >= cboAccounts.Width Then txtPayAgainst.Text = ptest1 GoTo l1 Else ptest = ptest & " " ptest1 = ptest End If Next l1: txtPayAgainst.Text = ptest1 txtpayee2.Visible = True txtpayee2.Text = payee2.Substring(ptest1.Length) ' txtPayAgainst.Text = payee2.Substring(0, 10) ' txtpayee2.Text = payee2.Substring(10) ' 'txtpayee2.Visible = True Else txtPayAgainst.Text = payee2 txtpayee2.Text = "" txtpayee2.Visible = False End If Catch ex As Exception MsgBox(ex.Message, , "Cheque Print") End Try End Sub
这篇关于根据文本框的宽度打印文本。而文本源是数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文