<<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:
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 MAPILab 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
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() 
        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:

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

Contents

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

Comments

No comments yet.