This project is read-only.
<<previous next>>

Example of work with Windows Forms

As another example of universality of MAPILab 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:
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 MAPILab Explorer For SharePoint"; 
        FlowLayoutPanel layoutPanel = new FlowLayoutPanel(); 
        layoutPanel.Dock = DockStyle.Fill; 
        TextBox textBox = new TextBox(); 
        textBox.Text = "Enter you name"; 
        Button button = new Button(); 
        button.Text = "Click Me!"; 

        // Output browser configuration
        //browser.Text = "Browser window";
        //browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded;
        browser.ReturnValue = form;
Visual Basic
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 MAPILab Explorer For SharePoint"
        Dim layoutPanel As FlowLayoutPanel = new FlowLayoutPanel() 
        layoutPanel.Dock = DockStyle.Fill
        Dim textBox As TextBox = new TextBox()
        textBox.Text = "Enter you name"
        Dim button As Button = new Button()
        button.Text = "Click Me!"
        ' 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:

Windows form

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:

Windows form with changed properties

<<previous next>>


Last edited Nov 27, 2009 at 8:53 AM by EugenMakarkhin, version 10


No comments yet.