
- #DISCUSSION BOARD EQUIVALENT FOR MAC IN SHAREPOINT 2013 HOW TO#
- #DISCUSSION BOARD EQUIVALENT FOR MAC IN SHAREPOINT 2013 CODE#
- #DISCUSSION BOARD EQUIVALENT FOR MAC IN SHAREPOINT 2013 WINDOWS#
#DISCUSSION BOARD EQUIVALENT FOR MAC IN SHAREPOINT 2013 CODE#
If the user pressed OK, the code inside the “If” block performs basically the same thing that the old Click and KeyDown event code used to do in each example. You also need to assign these dialog result values to the corresponding buttons. However, this return value is normally intended to tell you how the user closed the form (OK, Cancel, Abort, Retry, Ignore, Yes, or No) depending on what buttons you’ve shown. In the original script, the return value of the ShowDialog() method was discarded by casting it to.

I stopped throwing away the dialog’s results.You simply assign the buttons to the form’s AcceptButton and CancelButton properties:
#DISCUSSION BOARD EQUIVALENT FOR MAC IN SHAREPOINT 2013 WINDOWS#
However, Windows Forms already has a much simpler way of accomplishing this. These sections of code were intended to allow you to press ENTER or Escape to activate the same effects as the OK and Cancel buttons.

You can see the complete scripts on GitHub: WinFormsExampleUpdates. However, I decided to clean up these scripts a bit, and I took a different approach. You can change the variable assignments to use a scope modifier, for example: There is a very quick-and-dirty way to “fix” these scripts. Script blocks are supposed to have their own scope, and variable assignments are local unless you specify otherwise. However, the current behavior in Windows PowerShell 3.0 is more in line with what I would expect to see. I honestly can’t tell you why it worked in Windows PowerShell 1.0 and Windows PowerShell 2.0, or why that behavior changed. It doesn’t modify any variable named $x in the parent scope where the rest of the code is running. However, this variable assignment is local to the script block. When the button is clicked, the results of $objTextBox.Text are assigned to variable $x, and the form is closed. This line assigns a script block as an event handler for the button’s Click event. All four examples had code similar to this: The main reason they no longer work has to do with variable scope. I’m going to focus on why they stopped working, and discuss some other cleanup I did on the code. I’m not going to spend a lot of time talking about most of the code in these examples. This week, we released updated versions of these topics on TechNet because people still seem to be interested in writing GUIs. I can’t tell you how many times I’ve seen people asking questions about why the code based on these examples doesn’t work. If you tried to run them after that, they would not work. These examples worked until Windows PowerShell 3.0 was released.
#DISCUSSION BOARD EQUIVALENT FOR MAC IN SHAREPOINT 2013 HOW TO#
In the early days of Windows PowerShell, there was a series of “Windows PowerShell Tip of the Week” posts about how to create GUIs with Windows PowerShell, including: He works in IT, and he mainly focuses on automation, configuration management, and production support of computers running the Windows Server operating system and point-of-sale systems for a large retail company. To read more of Dave’s previous guest posts, see these Hey, Scripting Guy! Blog posts.ĭave is a Windows PowerShell MVP and a member of the board of directors at. Microsoft Scripting Guy, Ed Wilson, is here. Summary: Microsoft PowerShell MVP, Dave Wyatt, talks about using Windows PowerShell GUI example code.
