This documentation is archived and is not being maintained.
OpenFileDialog::ShowReadOnly Property
Visual Studio 2010
Gets or sets a value indicating whether the dialog box contains a read-only check box.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System::Booleantrue if the dialog box contains a read-only check box; otherwise, false. The default value is false.
The following code example demonstrates the use of the ShowReadOnly property. This example displays the OpenFileDialog box with the ShowReadOnly property set to true. If the user clicks the option to open the file in read-only mode, the OpenFile method is used to open the file. Otherwise, the FileStream class is used to open the file in read/write mode.
private: FileStream^ OpenFile() { // Displays an OpenFileDialog and shows the read/only files. OpenFileDialog^ dlgOpenFile = gcnew OpenFileDialog; dlgOpenFile->ShowReadOnly = true; if ( dlgOpenFile->ShowDialog() == ::DialogResult::OK ) { // If ReadOnlyChecked is true, uses the OpenFile method to // open the file with read/only access. if ( dlgOpenFile->ReadOnlyChecked == true ) { return dynamic_cast<FileStream^>(dlgOpenFile->OpenFile()); } // Otherwise, opens the file with read/write access. else { String^ path = dlgOpenFile->FileName; return gcnew FileStream( path,System::IO::FileMode::Open,System::IO::FileAccess::ReadWrite ); } } return nullptr; }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: