Console.CursorVisible プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Console.CursorVisible プロパティの意味・解説 

Console.CursorVisible プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

カーソル表示するかどうかを示す値を取得または設定します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Property CursorVisible
 As Boolean
Dim value As Boolean

value = Console.CursorVisible

Console.CursorVisible = value
public static bool CursorVisible
 { get; set; }
/** @property */
public static boolean get_CursorVisible ()

/** @property */
public static void set_CursorVisible
 (boolean value)

プロパティ
カーソル表示する場合trueそれ以外場合false

例外例外
例外種類条件

SecurityException

ユーザーに、この操作実行するためのアクセス許可がありません。

IOException

I/O エラー発生しました

解説解説
使用例使用例

CursorVisible プロパティ使用例次に示します。この例では、入力内容最初の列が '+' 文字である場合カーソル表示し、'-' 文字場合は非表示にしています。

' This example demonstrates the Console.CursorVisible property.
Imports System
Imports Microsoft.VisualBasic

Class Sample
   Public Shared Sub Main()
      Dim m1 As String =
 vbCrLf & "The cursor is {0}." & _
                         vbCrLf & "Type any text then press
 Enter. " & _
                         "Type '+' in the first column to show
 " & _
                         vbCrLf & "the cursor, '-' to hide
 the cursor, " & _
                         "or lowercase 'x' to quit:"
      Dim s As String
      Dim saveCursorVisibile As Boolean
      Dim saveCursorSize As Integer
      '
      Console.CursorVisible = True ' Initialize the
 cursor to visible.
      saveCursorVisibile = Console.CursorVisible
      saveCursorSize = Console.CursorSize
      Console.CursorSize = 100 ' Emphasize the cursor.
      While True
         Console.WriteLine(m1, _
            IIf(Console.CursorVisible = True, "VISIBLE",
 "HIDDEN"))
         s = Console.ReadLine()
         If String.IsNullOrEmpty(s) = False
 Then
            If s(0) = "+"c Then
               Console.CursorVisible = True
            ElseIf s(0) = "-"c
 Then
               Console.CursorVisible = False
            ElseIf s(0) = "x"c
 Then
               Exit While
            End If
         End If
      End While
      Console.CursorVisible = saveCursorVisibile
      Console.CursorSize = saveCursorSize
   End Sub 'Main
End Class 'Sample 
'
'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
'
// This example demonstrates the Console.CursorVisible property.

using System;

class Sample 
{
    public static void 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.

    while(true) 
        {
        Console.WriteLine(m1, 
                         ((Console.CursorVisible == true) ? 
                           "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

*/
// 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

*/
// This example demonstrates the Console.CursorVisible property.
import System.*;

class Sample
{
    public static void main(String[]
 args)
    {
        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;
        boolean saveCursorVisibile;
        int saveCursorSize;
        //
        Console.set_CursorVisible(true); // Initialize
 the cursor to visible.
        saveCursorVisibile = Console.get_CursorVisible();
        saveCursorSize = Console.get_CursorSize();
        Console.set_CursorSize(100); // Emphasize the cursor.
        while (true) {
            Console.WriteLine(m1, (Console.get_CursorVisible() == true)
 ? 
                "VISIBLE" : "HIDDEN");
            s = Console.ReadLine();
            if (String.IsNullOrEmpty(s) == false)
 {
                if (s.get_Chars(0) == '+') {
                    Console.set_CursorVisible(true);
                }
                else {
                    if (s.get_Chars(0) == '-') {
                        Console.set_CursorVisible(false);
                    }
                    else {
                        if (s.get_Chars(0) == 'x') {
                            break;
                        }
                    }
                }
            }
        }
        Console.set_CursorVisible(saveCursorVisibile);
        Console.set_CursorSize(saveCursorSize);
    } //main
} //Sample 
/*
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

*/
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からConsole.CursorVisible プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からConsole.CursorVisible プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からConsole.CursorVisible プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Console.CursorVisible プロパティ」の関連用語

Console.CursorVisible プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Console.CursorVisible プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS