Product, version and build: latest
32 or 64 bit version of product: 64
Operating system: W2K12R2
32 or 64 bit OS: 64
PowerShell Version: latest
DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
Hi,
I have this code (below) to make sure when a user clicks a cell in a gridview, it takes the values $Computer and $User. This works fine for a mouse click but not for a right mouse click (tried mouse down, cell mouse down but nothing works), please advise. When a user click left mouse a text appears with computername and username, right mouse nothing happens.
$datagridviewComputer_CellClick = [System.Windows.Forms.DataGridViewCellEventHandler]{
try
{
$Global:ComputerName = $datagridviewComputer.CurrentRow.Cells[0].Value
$Global:UserName = $datagridviewComputer.CurrentRow.Cells[1].Value
Add-Logs -text "Your selection: Computer $ComputerName and User $UserName"
}
Right click cell doesn't read content
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Right click cell doesn't read content
[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Right click cell doesn't read content
Ok, so that leaves me fully in the dark. What is the way to make it work then?
Re: Right click cell doesn't read content
Make what work? To click a cell just event the "CellContentClick" event. Look at the events under the DGV.stevenbaert wrote:Ok, so that leaves me fully in the dark. What is the way to make it work then?
- [Codebox=powershell file=Untitled.ps1]
- $datagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
- }
Re: Right click cell doesn't read content
To capture right click you can capture the MouseDown event like this:
- $datagridview1_MouseDown=[System.Windows.Forms.MouseEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
- Write-Host $_.Button
- }
Re: Right click cell doesn't read content
MouseDown was all I need, thanks!
It captures as well left mouse as right mouse actions.
Got rid of other mouseactions.
It captures as well left mouse as right mouse actions.
Got rid of other mouseactions.