Home > Blockchain >  Select pixel in WinForms PictureBox PowerShell
Select pixel in WinForms PictureBox PowerShell

Time:12-09

I develop a program with PowerShell and the assembly Windows Forms like the standard paint. I can load images and edit it, but I want to add a new tool: After clicking on the picture, I want to display the co-ordinates of the selected pixel in a TextBox.

A section of my program window.

The problem is how to get the co-ordinates from the selected pixel?

Thanks for your help!

CodePudding user response:

The PictureBox class inherits a MouseClick event you can subscribe to:

$pictureBox.add_MouseClick({
  param($sender, $mouseEventArgs)

  Write-Host "PictureBox was clicked at location $($mouseEventArgs.Location)"
})
  • Related