SelectionColor property not workingin GUI

Welcome Forums General PowerShell Q&A SelectionColor property not workingin GUI

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

      Hi

      I am trying to change the text color but received below error.

      The property ‘SelectionColor’ cannot be found on this object. Verify that the property exists and can be set.
      At C:\Users\Muhammad Suhail\Desktop\script\work\Patching Team\temp.ps1:72 char:9
      + $outputBox.SelectionColor = “#FF0000”
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyAssignmentException

       

      Code:

      • This topic was modified 1 month, 1 week ago by mrdon03.
    • #264431
      Participant
      Topics: 2
      Replies: 380
      Points: 513
      Helping Hand
      Rank: Major Contributor

      You haven’t provided enough information for this forum to help you.

      Without knowing what class of object $outputBox is, no one will be able to tell you if SelectionColor is a valid property and if it can be set or is read only.

      The error implies that the property does not exist.  You can check this by piping $outputBox to Get-Member

       

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

      Code Updated:

      • This reply was modified 1 month, 1 week ago by mrdon03.
    • #264578
      Participant
      Topics: 2
      Replies: 380
      Points: 513
      Helping Hand
      Rank: Major Contributor

      That should work fine with RichTextBox.  In fact, after adding the addtional code necessary to create the form, your code works as expected and I don’t get the error you posted in your original post.

      As previously advised, I would pipe $outputBox to Get-Member to check it’s the class of object you think it is.

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