Hide

SftDirectory 3.5 - ActiveX File/Folder Control

Display
Print

PrintPreview Sample (C#)

This sample illustrates SftDirectory and SftPrintPreview/OCX to print and preview file/folder listings.

The source code is located at C:\Program Files (x86)\Softelvdm\SftDirectory 3.5\Samples\Visual Studio - CSharp\PrintPreview\Form1.cs or C:\Program Files\Softelvdm\SftDirectory 3.5\Samples\Visual Studio - CSharp\PrintPreview\Form1.cs (on 32-bit Windows versions).

private void Form1_Load(object sender, System.EventArgs e)
{
    // Connect the directory control to the print preview control
    axSftPrintPreview1.ContentProvider = axSftDirectory1.Window;
    // display directory
    ShowDirectory();
    axSftPrintPreview1.ZoomFactor = 100;
    // maximize window
    WindowState = FormWindowState.Maximized;
}

private void ShowDirectory()
{
    // Show the SftDirectory control
    axSftDirectory1.Visible = true;
    axSftDirectory1.Enabled = true;
    axSftDirectory1.Dock = DockStyle.Fill;
    PerformLayout();
    axSftDirectory1.Focus();
    // Disable & hide the print preview control
    axSftPrintPreview1.Visible = false;
    axSftPrintPreview1.Enabled = false;
}

private void ShowPreview()
{
    // Show the print preview control
    axSftPrintPreview1.Visible = true;
    axSftPrintPreview1.Enabled = true;
    axSftPrintPreview1.Dock = DockStyle.Fill;
    PerformLayout();
    axSftPrintPreview1.Focus();
    // Disable & hide the SftDirectory control
    axSftDirectory1.Visible = false;
    axSftDirectory1.Enabled = false;
}

private void axSftPrintPreview1_PageSetupWanted(object sender, System.EventArgs e)
{
    axSftPrintPreview1.PageSetup(0);
}

private void axSftPrintPreview1_HelpWanted(object sender, AxSftPrintPreviewLib10._ISftPrintPreviewEvents_HelpWantedEvent e)
{
    MessageBox.Show("Sorry, this sample doesn't offer a help file");
}

private void axSftPrintPreview1_CloseWanted(object sender, System.EventArgs e)
{
    ShowDirectory();
}

private void menuExit_Click(object sender, System.EventArgs e)
{
    Application.Exit();
}

private void menuDirectory_Click(object sender, System.EventArgs e)
{
    ShowDirectory();
}

private void menuPreview_Click(object sender, System.EventArgs e)
{
    ShowPreview();
}

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