在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