locked
How to make a text box as transparent using powershell RRS feed

  • Question

  • How to make a text box as transparent using <g class="gr_ gr_4 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="4" id="4">powershell</g>


    $outputBox = New-Object System.Windows.Forms.RichTextBox
    $outputBox.Location = New-Object System.Drawing.Size(1090,100) 
    $outputBox.Size = New-Object System.Drawing.Size(480,545)
    #$outputBox.Font = New-Object System.Drawing.Font("Consolas", 8 ,[System.Drawing.FontStyle]::Regular)
    $outputBox.MultiLine = $True
    $outputBox.ScrollBars = "Vertical"
    $outputBox.AppendText("`n")
    $outputBox.ReadOnly = $True
    $outputBox.BackColor = "Color.Transparent"
    $Form.Controls.Add($outputBox)

    Exception setting "BackColor": "Control does not support transparent background colors."
    At line:49 char:1
    + $outputBox.BackColor = "Transparent"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
        + FullyQualifiedErrorId : ExceptionWhenSetting

    Tuesday, February 5, 2019 4:46 PM

All replies

  • Code from this blog post may help:

    https://blogs.technet.microsoft.com/stephap/2012/04/23/building-forms-with-powershell-part-1-the-form/

    In brief:

    Add-Type -AssemblyName System.Windows.Forms 
    $Form = New-Object system.Windows.Forms.Form
    $Form.Text = "Sample Form"
    $Form.Opacity = 0.7
        # 1.0 is fully opaque; 0.0 is invisible
    Edit: The RichTextBox class does not appear to have a similar property.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)


    Tuesday, February 5, 2019 6:45 PM
  • The error is explicit: Exception setting "BackColor": "Control does not support transparent background colors."

    You cannot set transparent background colors on a textbox.


    \_(ツ)_/

    Tuesday, February 5, 2019 6:49 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Thursday, February 21, 2019 6:39 AM