Table of Contents

Property ImportedNamespaces

Namespace
Alternet.FormDesigner.WinForms
Assembly
Alternet.FormDesigner.v9.dll

ImportedNamespaces

In case of Visual Basic, gets collection of globally available namespaces.

[Browsable(false)]
public DesignerImportedNamespaces ImportedNamespaces { get; set; }

Property Value

DesignerImportedNamespaces

Examples

Here is how to use a ImportedNamespaces in the C# code:

using System.IO;

using Alternet.FormDesigner.WinForms;

public partial class Form1 : Form
{
    private void Form1_Load(object sender, EventArgs e)
    {
        var formDesigner = new FormDesignerControl();
        formDesigner.AutoSaveToSource = false;
        formDesigner.Dock = System.Windows.Forms.DockStyle.Fill;
        formDesigner.Parent = this;
        string fileName = "myfile.vb";
        formDesigner.ImportedNamespaces = GetImportedNamespaces(fileName);
    }

    private DesignerImportedNamespaces GetImportedNamespaces(string fileName)
    {
        if (!Path.GetExtension(fileName).ToLower().Equals(".vb"))
            return null;

        return DesignerImportedNamespaces.DefaultForVisualBasic;
    }
}

Here is how to use a ImportedNamespaces in the Visual Basic code:

Imports System
Imports System.IO
Imports Alternet.FormDesigner.WinForms

Partial Public Class Form1
    Inherits Form

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim formDesigner = New FormDesignerControl()
        formDesigner.AutoSaveToSource = False
        formDesigner.Dock = System.Windows.Forms.DockStyle.Fill
        formDesigner.Parent = Me
        Dim fileName As String = "myfile.vb"
        formDesigner.ImportedNamespaces = GetImportedNamespaces(fileName)
    End Sub

    Private Function GetImportedNamespaces(ByVal fileName As String) As DesignerImportedNamespaces
        If Not Path.GetExtension(fileName).ToLower().Equals(".vb") Then Return Nothing
        Return DesignerImportedNamespaces.DefaultForVisualBasic
    End Function
End Class

Remarks

In order to alter ImportedNamespaces collection, you should create a new DesignerImportedNamespaces instance with the updated list of namespaces.