0
好吧,我想建立一個全球性的風格對我的表格的所有RichTextBox的:對於每TypeOf運算不工作(不收取任何的RichTextBox文本)在VB.NET
有了:
Public Class RichTextLabel
Public Shared Sub AddTextWithFont(ByVal sText As String, ByVal oFont As Font)
For Each cControl In frmMain.Controls
If (TypeOf cControl Is RichTextBox) Then
Dim index As Integer
index = cControl.TextLength
cControl.AppendText(sText)
cControl.SelectionStart = index
cControl.SelectionLength = cControl.TextLength - index
cControl.SelectionFont = oFont
End If
Next
End Sub
Public Shared Sub AddTextWithColor(ByVal sText As String, ByVal oColor As Color)
For Each cControl In frmMain.Controls
If (TypeOf cControl Is RichTextBox) Then
Dim index As Integer
index = cControl.TextLength
cControl.AppendText(sText)
cControl.SelectionStart = index
cControl.SelectionLength = cControl.TextLength - index
cControl.SelectionColor = oColor
End If
Next
End Sub
末級
和:
RichTextLabel.AddTextWithFont("Estado del Spammer: ", New Font("Microsoft Sans Serif", 8, FontStyle.Bold))
RichTextLabel.AddTextWithColor(state, Color.Red)
我不知道它錯了... :(
不工作並沒有告訴我們任何東西。你的意思是什麼都行不通 - 它沒有做任何事情,是否會拋出異常,等等。 – Tim
你爲什麼認爲有什麼不對?當您嘗試運行代碼時會發生什麼,以及它與您期望的有什麼不同?你有任何錯誤信息? – Guffa
它沒有做任何事情,所有的文字都是空白的。 – Seazoux