Console.CursorSize Console.CursorSize Console.CursorSize Console.CursorSize Property

Определение

Возвращает или задает высоту курсора в символьной ячейке.Gets or sets the height of the cursor within a character cell.

public:
 static property int CursorSize { int get(); void set(int value); };
public static int CursorSize { get; set; }
member this.CursorSize : int with get, set
Public Shared Property CursorSize As Integer

Значение свойства

Размер курсора, выраженный как процент от высоты символьной ячейки.The size of the cursor expressed as a percentage of the height of a character cell. Данное свойство принимает значения в диапазоне от 1 до 100.The property value ranges from 1 to 100.

Исключения

Значение, указанное в операции задания, меньше 1 или больше 100.The value specified in a set operation is less than 1 or greater than 100.

Данный пользователь не имеет разрешения на выполнение этого действия.The user does not have permission to perform this action.

Ошибка ввода/вывода.An I/O error occurred.

Операция задания вызывается в операционной системе, отличной от Windows.The set operation is invoked on an operating system other than Windows.

Примеры

В этом примере показано CursorSize свойство.This example demonstrates the CursorSize property. В примере выполняется увеличение размера курсора при каждом клавиши консоли нажата, а затем восстанавливает курсор становится равным исходному размеру перед завершением работы.The example increases the size of the cursor each time any console key is pressed, then restores the cursor to its original size before terminating.

// 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.
Imports System
Imports Microsoft.VisualBasic

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 'Main
End Class 'Sample
'
'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...)
'

Комментарии

Внешний вид курсора меняется от горизонтальную линию в нижней части ячейки, когда свойство имеет значение 1, до полного заполнения ячейки, когда значение свойства равно 100.The cursor appearance varies, ranging from a horizontal line at the bottom of the cell when the property value is 1, to completely filling the cell when the property value is 100.

Безопасность

UIPermission
для изменения безопасные окна верхнего уровня и подокнах.for modifying safe top-level windows and subwindows. Связанное перечисление: SafeTopLevelWindowsAssociated enumeration: SafeTopLevelWindows

Применяется к