在RichTextBox的特定顏色我已經創建在代碼中,你可以寫WritetoConsole(SomeString, LogType)
但是當日志類型被激活,(每個類型的日誌,不同的顏色),它改變了整個色的方法richtextbox,而不是輸入的實際行。如何更改線路,以基於子
它應該是在WinForm應用程序自定義控制檯。所以基本上無論輸入到Message
什麼都應該寫入控制檯,取決於LogitType。但我不希望它改變整個RichTextBox的文本顏色。我只是想這就是BEING進入
Dim NewLine As String = (Chr(13))
Dim LogType As LogerType
''' <summary>
''' Writes a Message to the Homework Helper Console
''' </summary>
''' <param name="Message">The Message to Display to Console</param>
''' <param name="LogitType">The Type of Message to Display to Console</param>
''' <remarks></remarks>
Public Sub WritetoConsole(Message As String, LogitType As Color)
LogerType.Normal = Color.White
LogerType.Warning = Color.Yellow
LogerType.ErrorMessage = Color.Maroon
LogerType.Homework = Color.Green
LogerType.Project = Color.Red
LogerType.Test = Color.RosyBrown
If Message = Nothing Then
rtbInput.AppendText(Errors(3))
Else
rtbInput.AppendText(NewLine & Message)
End If
If LogitType = LogerType.Normal Then
rtbInput.ForeColor = LogerType.Normal
ElseIf LogitType = LogerType.Warning Then
rtbInput.ForeColor = LogerType.Warning
ElseIf LogitType = LogerType.ErrorMessage Then
rtbInput.ForeColor = LogerType.ErrorMessage
ElseIf LogitType = LogerType.Homework Then
rtbInput.ForeColor = LogerType.Homework
ElseIf LogitType = LogerType.Project Then
rtbInput.ForeColor = LogerType.Project
ElseIf LogitType = LogerType.Test Then
rtbInput.ForeColor = LogerType.Test
ElseIf LogitType = Nothing Then
WritetoConsole((Errors(3)), LogerType.ErrorMessage)
Else
MsgBox(Errors(4))
End If
End Sub
你你的寫作沒有寫入控制檯一個RichTextBox,非常不同。 – Codexer
另外你已經聲明一個變量logtype爲logertype,但不使用它。我會把它們放在一個枚舉中並以這種方式使用它們。 – Codexer
@MrCoDeXeR rtbInput.AppendText(換行和消息)添加到RichTextBox中,使它看起來像一個控制檯...使子過程WritetoConsole(消息作爲字符串,LogitType顏色)使其能夠工作就像是使用WritetoConsole控制檯(消息,LogitType) – user2678408