C# 開発

C# マウスカーソルを待機状態に変更する (1)

準備

(なし)

デザイン

  1. フォーム (Form1) にボタン (button1) を配置します。
  2. フォーム (Form1) にボタン (button1) を配置します。
  3. フォーム (Form1) にリストボックス (listBox1) を配置します。

サンプルコード (C#)

// 名前空間の追加
// (なし)

// コード
private void button1_Click(object sender, EventArgs e)
{
  this.Cursor = Cursors.WaitCursor;
}

private void button2_Click(object sender, EventArgs e)
{
  this.Cursor = Cursors.Default;
}

解説

button1 をクリックすると待機状態に、button2 をクリックするとデフォルトに戻ります。

結果

動作確認環境

Visual Studio 2022 Professional (.NET 7 C#11)

ログ

初版:2016.06.02 Visual Studio 2015 Professional (C# 6.0)

-C# 開発