Console.CursorSize Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft die Höhe des Cursors innerhalb einer Zeichenzelle ab oder legt diese fest.
public:
static property int CursorSize { int get(); void set(int value); };
public static int CursorSize { [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
public static int CursorSize { [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] [System.Runtime.Versioning.UnsupportedOSPlatform("android")] [System.Runtime.Versioning.UnsupportedOSPlatform("ios")] [System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
public static int CursorSize { get; set; }
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.CursorSize : int with get, set
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
member this.CursorSize : int with get, set
member this.CursorSize : int with get, set
Public Shared Property CursorSize As Integer
Eigenschaftswert
Die Größe des Cursors in Prozent der Höhe einer Zeichenzelle. Der Eigenschaftswert liegt zwischen 1 und 100.
- Attribute
Ausnahmen
Der in einem Set-Vorgang angegebene Wert ist kleiner als 1 oder größer als 100.
Der Benutzer verfügt nicht über die erforderlichen Berechtigung, um diese Aktion durchzuführen.
E/A-Fehler
Der set-Vorgang wird unter einem anderen Betriebssystem als Windows aufgerufen.
Beispiele
In diesem Beispiel wird die -Eigenschaft CursorSize veranschaulicht. Im Beispiel wird die Größe des Cursors jedes Mal erhöht, wenn eine Konsolentaste gedrückt wird. Anschließend wird der Cursor auf seine ursprüngliche Größe wiederhergestellt, bevor er beendet wird.
// This example demonstrates the Console.CursorSize property.
using namespace System;
int main()
{
String^ m0 = "This example increments the cursor size from 1% to 100%:\n";
String^ m1 = "Cursor size = {0}%. (Press any key to continue...)";
array<Int32>^sizes = {1,10,20,30,40,50,60,70,80,90,100};
int saveCursorSize;
//
saveCursorSize = Console::CursorSize;
Console::WriteLine( m0 );
System::Collections::IEnumerator^ myEnum = sizes->GetEnumerator();
while ( myEnum->MoveNext() )
{
int size = *safe_cast<Int32^>(myEnum->Current);
Console::CursorSize = size;
Console::WriteLine( m1, size );
Console::ReadKey();
}
Console::CursorSize = saveCursorSize;
}
/*
This example produces the following results:
This example increments the cursor size from 1% to 100%:
Cursor size = 1%. (Press any key to continue...)
Cursor size = 10%. (Press any key to continue...)
Cursor size = 20%. (Press any key to continue...)
Cursor size = 30%. (Press any key to continue...)
Cursor size = 40%. (Press any key to continue...)
Cursor size = 50%. (Press any key to continue...)
Cursor size = 60%. (Press any key to continue...)
Cursor size = 70%. (Press any key to continue...)
Cursor size = 80%. (Press any key to continue...)
Cursor size = 90%. (Press any key to continue...)
Cursor size = 100%. (Press any key to continue...)
*/
// This example demonstrates the Console.CursorSize property.
using System;
class Sample
{
public static void Main()
{
string m0 = "This example increments the cursor size from 1% to 100%:\n";
string m1 = "Cursor size = {0}%. (Press any key to continue...)";
int[] sizes = {1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
int saveCursorSize;
//
saveCursorSize = Console.CursorSize;
Console.WriteLine(m0);
foreach (int size in sizes)
{
Console.CursorSize = size;
Console.WriteLine(m1, size);
Console.ReadKey();
}
Console.CursorSize = saveCursorSize;
}
}
/*
This example produces the following results:
This example increments the cursor size from 1% to 100%:
Cursor size = 1%. (Press any key to continue...)
Cursor size = 10%. (Press any key to continue...)
Cursor size = 20%. (Press any key to continue...)
Cursor size = 30%. (Press any key to continue...)
Cursor size = 40%. (Press any key to continue...)
Cursor size = 50%. (Press any key to continue...)
Cursor size = 60%. (Press any key to continue...)
Cursor size = 70%. (Press any key to continue...)
Cursor size = 80%. (Press any key to continue...)
Cursor size = 90%. (Press any key to continue...)
Cursor size = 100%. (Press any key to continue...)
*/
// This example demonstrates the Console.CursorSize property.
open System
let sizes = [ 1; 10; 20; 30; 40; 50; 60; 70; 80; 90; 100 ]
let saveCursorSize = Console.CursorSize
printfn "This example increments the cursor size from 1%% to 100%%:\n"
for size in sizes do
Console.CursorSize <- size
printfn $"Cursor size = {size}%%. (Press any key to continue...)"
Console.ReadKey() |> ignore
Console.CursorSize <- saveCursorSize
// This example produces the following results:
// This example increments the cursor size from 1% to 100%:
// Cursor size = 1%. (Press any key to continue...)
// Cursor size = 10%. (Press any key to continue...)
// Cursor size = 20%. (Press any key to continue...)
// Cursor size = 30%. (Press any key to continue...)
// Cursor size = 40%. (Press any key to continue...)
// Cursor size = 50%. (Press any key to continue...)
// Cursor size = 60%. (Press any key to continue...)
// Cursor size = 70%. (Press any key to continue...)
// Cursor size = 80%. (Press any key to continue...)
// Cursor size = 90%. (Press any key to continue...)
// Cursor size = 100%. (Press any key to continue...)
' This example demonstrates the Console.CursorSize property.
Class Sample
Public Shared Sub Main()
Dim m0 As String = "This example increments the cursor size from " & _
"1% to 100%:" & vbCrLf
Dim m1 As String = "Cursor size = {0}%. (Press any key to continue...)"
Dim sizes As Integer() = {1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
Dim saveCursorSize As Integer
'
saveCursorSize = Console.CursorSize
Console.WriteLine(m0)
Dim size As Integer
For Each size In sizes
Console.CursorSize = size
Console.WriteLine(m1, size)
Console.ReadKey()
Next size
Console.CursorSize = saveCursorSize
End Sub
End Class
'
'This example produces the following results:
'
'This example increments the cursor size from 1% to 100%:
'
'Cursor size = 1%. (Press any key to continue...)
'Cursor size = 10%. (Press any key to continue...)
'Cursor size = 20%. (Press any key to continue...)
'Cursor size = 30%. (Press any key to continue...)
'Cursor size = 40%. (Press any key to continue...)
'Cursor size = 50%. (Press any key to continue...)
'Cursor size = 60%. (Press any key to continue...)
'Cursor size = 70%. (Press any key to continue...)
'Cursor size = 80%. (Press any key to continue...)
'Cursor size = 90%. (Press any key to continue...)
'Cursor size = 100%. (Press any key to continue...)
'
Hinweise
Die Darstellung des Cursors variiert von einer horizontalen Linie am unteren Rand der Zelle, wenn der Eigenschaftswert 1 ist, bis hin zum vollständigen Auffüllen der Zelle, wenn der Eigenschaftswert 100 ist.