Cant get add_click event to return or pass data using monthcalendar

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
Post Reply
pjbuckley
Posts: 31
Joined: Tue Nov 05, 2019 3:44 pm

Cant get add_click event to return or pass data using monthcalendar

Post by pjbuckley » Fri Nov 15, 2019 6:11 pm

This same exact code works well in a function i found yet wont work for me. The add_click code looks like this:
  1.     $Button1.add_Click({
  2.  
  3.         for(
  4.  
  5.         $MO = $cal.SelectionRange.Start;
  6.  
  7.         $MO -le $cal.SelectionRange.End;
  8.  
  9.         $MO = $MO.AddDays(1)
  10.  
  11.         )
  12.  
  13.         {
  14.  
  15.         $Global:MO #| get-date -Uformat %B
  16.  
  17.         }
  18.  
  19.     })
I have attached the complete code base in case there is something else im missing but i am stumped at this point.
Attachments
Choose-month.ps1
(5.6 KiB) Downloaded 12 times

jvierra
Posts: 14015
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Cant get add_click event to return or pass data using monthcalendar

Post by jvierra » Fri Nov 15, 2019 8:09 pm

The syntax of the code is wrong and the code makes little sense.

This is the best guess at what you are trying to do:

Code: Select all

for($MO = $cal.SelectionRange.Start;$MO -le $cal.SelectionRange.End;$MO = $MO.AddDays(1)){  
    Write-Host $MO #| get-date -Uformat %B
}

Post Reply