OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

POWERSHELL Forms: How to change button colors (fore- and backColor) on mouseover

  • Thread starter Thread starter Tribun
  • Start date Start date
T

Tribun

Guest
I'm on WINDOWS 10 and POWERSHELL 7.4.3.

I want to change the colors (fore- and backColor) of a button-control when the mouse hovers/leaves the button. Here is an excerpt of the button-control-settings:

Code:
$MyButton = New-Object System.Windows.Forms.Button
$MyButton.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat
$MyButton.Font = New-Object System.Drawing.Font("Roboto", 12,[System.Drawing.FontStyle]::Bold,[System.Drawing.GraphicsUnit]::Point, 0)
$MyButton.Location = New-Object System.Drawing.Point(5, 112)
$MyButton.Name = "MyButton"
$MyButton.Text = "My button"
$MyButton.Size = New-Object System.Drawing.Size(150, 40)

I tried adding

Code:
$MyButton.Add_MouseHover({$MyButton.Color = [System.Drawing.Color]::Orange})

to change the foreColor but the color does not change when the mouse hovers the button.

Any suggestions?

Peace​

<p>I'm on WINDOWS 10 and POWERSHELL 7.4.3.</p>
<p>I want to change the colors (fore- and backColor) of a button-control when the mouse hovers/leaves the button. Here is an excerpt of the button-control-settings:</p>
<pre><code>$MyButton = New-Object System.Windows.Forms.Button
$MyButton.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat
$MyButton.Font = New-Object System.Drawing.Font("Roboto", 12,[System.Drawing.FontStyle]::Bold,[System.Drawing.GraphicsUnit]::Point, 0)
$MyButton.Location = New-Object System.Drawing.Point(5, 112)
$MyButton.Name = "MyButton"
$MyButton.Text = "My button"
$MyButton.Size = New-Object System.Drawing.Size(150, 40)
</code></pre>
<p>I tried adding</p>
<pre><code>$MyButton.Add_MouseHover({$MyButton.Color = [System.Drawing.Color]::Orange})
</code></pre>
<p>to change the foreColor but the color does not change when the mouse hovers the button.</p>
<p>Any suggestions?</p>
<h1>Peace</h1>
Continue reading...
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top