Change the font colour output that display in System.Windows.Forms.RichTextBox

Welcome Forums General PowerShell Q&A Change the font colour output that display in System.Windows.Forms.RichTextBox

Viewing 3 reply threads
  • Author
    Posts
    • #259329
      Participant
      Topics: 4
      Replies: 7
      Points: 58
      Rank: Member

      Hi

      I am trying to change the font colour output that display in System.Windows.Forms.RichTextBox
      Below is the code

      function pingInfo {
      $outputBox.Clear()
      $computers = $InputBox.lines.Split("`n") &lt;/code&gt;<br />&lt;code&gt;foreach ($computer in $computers) { &lt;/code&gt;<br />&lt;code&gt;if (Test-Connection $computer -Count 1 -Quiet) {&lt;/code&gt;<br />&lt;code&gt;$serveronline = "$computer is online"&lt;/code&gt;<br />&lt;code&gt;$outputBox.Appendtext("{0}`n" -f $serveronline)
      }
      else {
      $serveroffline = "$computer is offline"
      $outputBox.Appendtext("{0}`n" -f $serveroffline)
      }
      }
      }

      For example I want “computer is online” in green and “computer is offline” in red

    • #259332
      Participant
      Topics: 4
      Replies: 7
      Points: 58
      Rank: Member

      Code updated:

    • #259792
      Participant
      Topics: 7
      Replies: 137
      Points: 668
      Helping Hand
      Rank: Major Contributor
    • #259912
      Participant
      Topics: 4
      Replies: 7
      Points: 58
      Rank: Member

      Resolved.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.