Getpict() Method

Getpict() Method

Visual FoxPro Toolkit for .NET

GetPict() Method

Displays the file open dialog box with specific file types for pictures.

This method is only available in WinForms and not available for ASP.NET WebForms.

[Visual Basic]

Public Shared Function GetPict() As String

[C#]

public static string GetPict()

Example

[Visual Basic]

Dim MyPictFile As String

MyPictFile = GetPict()

MessageBox(MyPictFile)

[C#]

string MyPictFile;

MyPictFile = VFPToolkit.dialogs.GetPict();

Implementation

[Visual Basic]

Public Shared Function GetPict() As String
Dim lcFile As String = ""
'Create the OpenFileDialog (note that the FileDialog class is an abstract and cannot be used directly)
Dim ofd As OpenFileDialog = New OpenFileDialog()
'Specify the default filter to use for displaying files
ofd.Filter = "All Files (*.*)|*.*|All Graphic Files (*.bmp;*.dib;*.jpg;*.cur;ani;*.ico;*.gif)|*.bmp;*.dib;*.jpg;*.cur;*.ani;*.ico;*.gif|Bitmap (*.bmp;*.dib)|*.bmp;*.dib|Cursor (*.cur)|*.cur|Animated Cursor (*.ani)|*.ani|Icon (*.ico)|*.ico|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif"
ofd.FilterIndex = 2
'Show the dialog and if the user selects a file return the file name
If ofd.ShowDialog() > DialogResult.Cancel Then
'get the name of the file
lcFile = ofd.FileName
End If
'return the file name
Return lcFile
End Function

[C#]

public static string GetPict()
{
string lcFile = "";
//Create the OpenFileDialog (note that the FileDialog class is an abstract and cannot be used directly)
OpenFileDialog ofd = new OpenFileDialog();
//Specify the default filter to use for displaying files
ofd.Filter = "All Files (*.*)|*.*|All Graphic Files (*.bmp;*.dib;*.jpg;*.cur;ani;*.ico;*.gif)|*.bmp;*.dib;*.jpg;*.cur;*.ani;*.ico;*.gif|Bitmap (*.bmp;*.dib)|*.bmp;*.dib|Cursor (*.cur)|*.cur|Animated Cursor (*.ani)|*.ani|Icon (*.ico)|*.ico|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif";
ofd.FilterIndex = 2;
//Show the dialog and if the user selects a file return the file name
if(ofd.ShowDialog() != DialogResult.Cancel)
{
//get the name of the file
lcFile = ofd.FileName;
}
//return the file name
return lcFile;
}

Requirements

Namespace: VFPToolkit

Class: VFPToolkit.dialogs

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family

Assembly: VFPToolkit (in VFPToolkitNET.dll)

See Also

VFPToolkit.dialogs Members | VFPToolkit Namespace