Example of work with Windows Forms
As another example of universality of MAPILab Spy for SharePoint, let`s review the operations with class System.Windows.Forms.Form.
Open new script window and modify text of method main the following way:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
public class Tester
{
static object main(
MAPILab.SharePoint.Spy.CodeForm thisForm
)
{
Form form = new Form();
form.Text = "Hello from MAPILab Spy for SharePoint";
FlowLayoutPanel layoutPanel = new FlowLayoutPanel();
form.Controls.Add(layoutPanel);
layoutPanel.Dock = DockStyle.Fill;
TextBox textBox = new TextBox();
textBox.Text = "Enter you name";
layoutPanel.Controls.Add(textBox);
Button button = new Button();
button.Text = "Click Me!";
layoutPanel.Controls.Add(button);
form.Show();
return form;
}
}
The given program code creates new window, adds several controls in it, after that it is displayed using method Show() and returns reference to window object for further investigation. The result of script execution looks the following way:
Click to open real size screenshot
Here, pay attention that properties of created window may be changed. By changing properties (without closing anything), our window can be made to look the following way:
Click to open real size screenshot
|