Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Issue creating Item Activated Events for a third party form Control in Windows Powershell

$
0
0

I was asked at work to look into converting some of our VB.Net Applications to PowerShell. We use theQIOS dev Suite for some of the controls to make it more visually appealing. I have been testing to controls out and I can load and create forms with no issue in powershell but I'm stumped on the error I'm receiving when I add and ItemActivated event. I need to make it so when a user clicks on a given menu Item the form gets which menu item is clicked. 

Below is the code to my test form.

[VOID][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[VOID][reflection.assembly]::LoadFile("C:\Code\Qios.DevSuite.Components.dll")

[System.Windows.Forms.Application]::EnableVisualStyles() 
$form1 = New-Object 'System.Windows.Forms.Form'
$Menu = New-Object 'Qios.DevSuite.Components.QCompositeControl'
$item = New-Object 'Qios.DevSuite.Components.QCompositeMenuItem'

$DOSOMETHING={Write-Host "DO SOMETHING"}

# form1
$form1.Controls.Add($Menu)
$form1.ClientSize = '202, 262'
$form1.Name = "form1"
$form1.Text = "Form"
$form1.add_Load($form1_Load)

#MenuItem
$Item.ItemName = "Test Item"
$Item.Title = "Test Item"


# Menu
$Menu.Location = '13, 12'
$Menu.Name = "panel1"
$Menu.Size = '177, 238'
$Menu.Items.Add($Item)
$Menu.Add_ItemActivated($DOSOMETHING)

$form1.ShowDialog()

If someone could take a look and tell me what I'm doing wrong that would be great. If you need the dll file below is a link to my copy.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>