Hide

SftDirectory 3.5 - ActiveX File/Folder Control

Display
Print

Selections Sample (C#)

This sample illustrates working with selections.

This is not an executable sample, so a complete project is not provided. These statements are intended to show the syntax used.

private void Form1_Load(object sender, System.EventArgs e)
{
    // This sample uses 2 SftDirectory controls
    // SftDirectory1 allows single selection only
    axSftDirectory1.MultiSelect = SftDirectoryMultiSelectConstants.selectSftDirectorySingle;
    // SftDirectory2 allows multiple selection
    axSftDirectory2.MultiSelect = SftDirectoryMultiSelectConstants.selectSftDirectoryMultiple;
}

// This is a button event handler
private void button1_Click(object sender, System.EventArgs e)
{
    // Select one file/folder (in a single selection control)
    axSftDirectory1.get_FolderList(1).Selected = true;
    // Select a few files/folders (in a multiple selection control)
    axSftDirectory2.get_FolderList(1).Selected = true;
    axSftDirectory2.get_FolderList(3).Selected = true;
    axSftDirectory2.get_FolderList(5).Selected = true;
}

// This is another button event handler
private void button2_Click(object sender, System.EventArgs e)
{
    // Show the selected file/folder (in a single selection control)
    SftDirectoryFolder F;
    F = axSftDirectory1.get_Selection(0);
    if (F != null) {
        MessageBox.Show("\"" + F.Name + "\" is selected (in the single selection control).");
    }
    // Show the selected files/folders (in a multiple selection control)
    int i;
    for (i = 0 ; i < axSftDirectory2.SelectionCount ; ++i) {
        F = axSftDirectory2.get_Selection(i);
        MessageBox.Show("\"" + F.Name + "\" is selected (in the multiple selection control).");
    }
}

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.