Hide

SftDirectory 3.5 - ActiveX File/Folder Control

Display
Print

SftDirectory.Filtering Event

A file/folder is added.

Syntax

VB.NETPrivate Sub object_Filtering(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.Filtering
VBPrivate Sub object_Filtering(Folder As SftDirectoryFolder, RemoveFolder As Boolean)
C#.NETvoid object_Filtering(object sender, EventArgumentType e);
VC++void OnFilteringobject(ISftDirectoryFolder** Folder, VARIANT_BOOL* RemoveFolder);
CHRESULT OnFilteringobject(ISftDirectoryFolder** Folder, VARIANT_BOOL* RemoveFolder);

object

A SftDirectory object.

Folder

Describes the SftDirectoryFolder being added to the control's contents.

RemoveFolder

Set to True to remove the folder from the control's contents or False to accept the folder.

Comments

The Filtering event occurs when a file/folder is added.

An application can decide to remove the folder as it is being added to the control, to implement application-specific filtering based on folder attributes or contents.

The AutoInitialLoad property may need to be set to False so the control does not load its contents immediately. This may be necessary if filtering is desired. The Filtering event may not occur when the control is initially created, due to certain environment restrictions. For example, in Visual Basic, the Filtering event is not generated until the Form_Load event has occurred. The control however is created before the Form_Load event occurs, preventing the Filtering events from being handled by the application. This in effect prevents any filtering from taking place. The solution is to set AutoInitialLoad to False and use the control's Reload method in the Form_Load event. Setting AutoInitialLoad to False isn't absolutely necessary, but it may save processing time as the control contents are only loaded once, in response to the Reload method.

Examples

VB.NET

    ' To avoid duplicate loading, use AutoInitialLoad = False in
    ' property page
    AxSftDirectory1.ControlStyle = SftDirectoryStyleConstants.styleSftDirectoryComboBoxDetailList
    AxSftDirectory1.TopMostFolderSpecial = SftDirectorySpecialFolderConstants.specialSftDirectoryMyComputer
    AxSftDirectory1.Headers.Style = SftDirectoryHeadersStyleConstants.headersSftDirectoryButton
    AxSftDirectory1.get_Column(SftDirectoryContentsConstants.contentsSftDirectoryName).HeaderText = "Drives"
End Sub

Private Sub AxSftDirectory1_Filtering(ByVal sender As Object, ByVal e As AxSftDirectoryLib30._ISftDirectoryEvents_FilteringEvent) Handles AxSftDirectory1.Filtering
    ' This filters out folders such as "Shared Documents", "Control Panel", which
    ' are part of "My Computer"
    If e.folder.Type >= SftDirectoryFolderTypeConstants.typeSftDirectory_Computer_Drive35 And _
            e.folder.Type <= SftDirectoryFolderTypeConstants.typeSftDirectory_Computer_Other Then
        ' OK, add this to the control contents
    Else
        e.removeFolder = True ' don't add this to the control contents

VB6

    ' To avoid duplicate loading, use AutoInitialLoad = False in
    ' property page
    SftDirectory1.ControlStyle = styleSftDirectoryComboBoxDetailList
    SftDirectory1.TopMostFolderSpecial = specialSftDirectoryMyComputer
    SftDirectory1.Headers.Style = headersSftDirectoryButton
    SftDirectory1.Column(contentsSftDirectoryName).HeaderText = "Drives"
End Sub

Private Sub SftDirectory1_Filtering(Folder As SftDirectoryLib30.ISftDirectoryFolder, RemoveFolder As Boolean)
    ' This filters out folders such as "Shared Documents", "Control Panel", which
    ' are part of "My Computer"
    If Folder.Type >= typeSftDirectory_Computer_Drive35 And Folder.Type <= typeSftDirectory_Computer_Other Then
        ' OK, add this to the control contents
    Else
        RemoveFolder = True ' don't add this to the control contents
    End If

C#

    // To avoid duplicate loading, use AutoInitialLoad = False in
    // property page
    axSftDirectory1.ControlStyle = SftDirectoryStyleConstants.styleSftDirectoryComboBoxDetailList;
    axSftDirectory1.TopMostFolderSpecial = SftDirectorySpecialFolderConstants.specialSftDirectoryMyComputer;
    axSftDirectory1.Headers.Style = SftDirectoryHeadersStyleConstants.headersSftDirectoryButton;
    axSftDirectory1.get_Column(SftDirectoryContentsConstants.contentsSftDirectoryName).HeaderText = "Drives";
}

private void axSftDirectory1_Filtering(object sender, AxSftDirectoryLib30._ISftDirectoryEvents_FilteringEvent e)
{
    // This filters out folders such as "Shared Documents", "Control Panel", which
    // are part of "My Computer"
    if (e.folder.Type >= SftDirectoryFolderTypeConstants.typeSftDirectory_Computer_Drive35 &&
            e.folder.Type <= SftDirectoryFolderTypeConstants.typeSftDirectory_Computer_Other)
        ;// OK, add this to the control contents
    else

C++

    m_vDir1->ControlStyle = styleSftDirectoryComboBoxDetailList;
    m_vDir1->TopMostFolderSpecial = specialSftDirectoryMyComputer;
    m_vDir1->Headers->Style = headersSftDirectoryButton;
    m_vDir1->Column[contentsSftDirectoryName]->HeaderText = "Drives";

    return TRUE;
}

void CFilteringDlg::OnFilteringSftDirectory1(LPDISPATCH FAR* Folder, BOOL FAR* RemoveFolder)
{
    ISftDirectoryFolderPtr pFolder(*Folder);

    // This filters out folders such as "Shared Documents", "Control Panel", which
    // are part of "My Computer"
    if (pFolder->Type >= typeSftDirectory_Computer_Drive35 && pFolder->Type <= typeSftDirectory_Computer_Other)
        ; // OK, add this to the control contents

See Also SftDirectory Object | Object Hierarchy


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