This documentation is archived and is not being maintained.
Console::CursorVisible Property
Visual Studio 2010
Gets or sets a value indicating whether the cursor is visible.
Assembly: mscorlib (in mscorlib.dll)
| Exception | Condition |
|---|---|
| SecurityException | The user does not have permission to perform this action. |
| IOException | An I/O error occurred. |
This example demonstrates the CursorVisible property. The example makes the cursor visible if the first column of input is a '+' character or invisible if the input is a '-' character.
// This example demonstrates the Console.CursorVisible property. using namespace System; int main() { String^ m1 = "\nThe cursor is {0}.\nType any text then press Enter. " "Type '+' in the first column to show \n" "the cursor, '-' to hide the cursor, " "or lowercase 'x' to quit:"; String^ s; bool saveCursorVisibile; int saveCursorSize; // Console::CursorVisible = true; // Initialize the cursor to visible. saveCursorVisibile = Console::CursorVisible; saveCursorSize = Console::CursorSize; Console::CursorSize = 100; // Emphasize the cursor. for ( ; ; ) { Console::WriteLine( m1, ((Console::CursorVisible == true) ? (String^)"VISIBLE" : "HIDDEN") ); s = Console::ReadLine(); if ( String::IsNullOrEmpty( s ) == false ) if ( s[ 0 ] == '+' ) Console::CursorVisible = true; else if ( s[ 0 ] == '-' ) Console::CursorVisible = false; else if ( s[ 0 ] == 'x' ) break; } Console::CursorVisible = saveCursorVisibile; Console::CursorSize = saveCursorSize; } /* This example produces the following results. Note that these results cannot depict cursor visibility. You must run the example to see the cursor behavior: The cursor is VISIBLE. Type any text then press Enter. Type '+' in the first column to show the cursor, '-' to hide the cursor, or lowercase 'x' to quit: The quick brown fox The cursor is VISIBLE. Type any text then press Enter. Type '+' in the first column to show the cursor, '-' to hide the cursor, or lowercase 'x' to quit: - The cursor is HIDDEN. Type any text then press Enter. Type '+' in the first column to show the cursor, '-' to hide the cursor, or lowercase 'x' to quit: jumps over The cursor is HIDDEN. Type any text then press Enter. Type '+' in the first column to show the cursor, '-' to hide the cursor, or lowercase 'x' to quit: + The cursor is VISIBLE. Type any text then press Enter. Type '+' in the first column to show the cursor, '-' to hide the cursor, or lowercase 'x' to quit: the lazy dog. The cursor is VISIBLE. Type any text then press Enter. Type '+' in the first column to show the cursor, '-' to hide the cursor, or lowercase 'x' to quit: x */
- UIPermission
for modifying safe top-level windows and subwindows. Associated enumeration: UIPermissionWindow::SafeTopLevelWindows
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: