HarePoint Explorer for SharePoint - Example of work with Windows Forms
 

Example of work with Windows Forms

As another example of universality of HarePoint Explorer 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:

C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using MAPILab.SharePoint.Explorer.CodeForm;
using MAPILab.SharePoint.Explorer.Utilities.ScriptRunner;
using System.Windows.Forms;

public class Tester
{
    static void Main(
         MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm thisForm
        ,MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser browser
        )
    {
        
        Form form = new Form(); 
        form.Text = "Hello From HarePoint Explorer 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();

        // Output browser configuration
        //browser.Text = "Browser window";
        //browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded;
        browser.ReturnValue = form;
    }
}

Visual Basic

Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports MAPILab.SharePoint.Explorer.CodeForm
Imports MAPILab.SharePoint.Explorer.Utilities.ScriptRunner
Imports System.Windows.Forms

Public Class Tester
    Shared Sub Main(ByVal thisForm As MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm, 
                    ByVal browser As MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser)
        
        Dim form As Form = new Form()
        form.Text = "Hello From HarePoint Explorer for SharePoint"
        Dim layoutPanel As FlowLayoutPanel = new FlowLayoutPanel() 
        form.Controls.Add(layoutPanel)
        layoutPanel.Dock = DockStyle.Fill
        Dim textBox As TextBox = new TextBox()
        textBox.Text = "Enter you name"
        layoutPanel.Controls.Add(textBox)
        Dim button As Button = new Button()
        button.Text = "Click Me!"
        layoutPanel.Controls.Add(button)
        form.Show()
        
        ' Output browser configuration
        'browser.Text = "Browser window"
        'browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded

        browser.ReturnValue = form
    End Sub
End Class

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:

Show 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:

Show screenshot