Control.Cursor プロパティ

定義

マウス ポインターがコントロールの上にあるときに表示されるカーソルを取得または設定します。

public:
 virtual property System::Windows::Forms::Cursor ^ Cursor { System::Windows::Forms::Cursor ^ get(); void set(System::Windows::Forms::Cursor ^ value); };
public virtual System.Windows.Forms.Cursor Cursor { get; set; }
member this.Cursor : System.Windows.Forms.Cursor with get, set
Public Overridable Property Cursor As Cursor

プロパティ値

Cursor

マウス ポインターがコントロールの上にあるときに表示されるカーソルを表す Cursor

次のコード例では、 ComboBox ユーザーが使用できる論理ドライブを入力します。 また、コンボ ボックスの Cursor プロパティを設定して、マウス ポインターがドロップダウン ボタンの上にあるときにカーソルが表示されるように Cursors.Hand します。 このコードでは、a を持っているFormComboBox必要があります。

private:
   void Form1_Load( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      // Display the hand cursor when the mouse pointer
      // is over the combo box drop-down button.
      comboBox1->Cursor = Cursors::Hand;
      
      // Fill the combo box with all the logical
      // drives available to the user.
      try
      {
         IEnumerator^ myEnum = Environment::GetLogicalDrives()->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            String^ logicalDrive = safe_cast<String^>(myEnum->Current);
            comboBox1->Items->Add( logicalDrive );
         }
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( ex->Message );
      }
   }
private void Form1_Load(object sender, EventArgs e)
{
   // Display the hand cursor when the mouse pointer
   // is over the combo box drop-down button. 
   comboBox1.Cursor = Cursors.Hand;

   // Fill the combo box with all the logical 
   // drives available to the user.
   try
   {
      foreach(string logicalDrive in Environment.GetLogicalDrives() )
      {
         comboBox1.Items.Add(logicalDrive);
      }
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}
Private Sub Form1_Load(sender As Object, _
  e As EventArgs) Handles MyBase.Load
   ' Display the hand cursor when the mouse pointer
   ' is over the combo box drop-down button. 
   comboBox1.Cursor = Cursors.Hand
   
   ' Fill the combo box with all the logical 
   ' drives available to the user. 
   Try
      Dim logicalDrive As String
      For Each logicalDrive In  Environment.GetLogicalDrives()
         comboBox1.Items.Add(logicalDrive)
      Next logicalDrive
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try
End Sub

注釈

Cursorマウス ポインターがCursorコントロールの上にあるときに表示されるカーソルを変更するには、コントロールのプロパティに a を割り当てます。 アプリケーション上のすべてのコントロールのマウス カーソルを一時的に変更するには、プロパティを Cursor.Current 設定します。 通常は、ファイルを Cursor.Current 設定または保存または読み込むときに、このプロパティを ComboBox 待機カーソルに設定します。

プロパティは Cursor アンビエント プロパティです。 アンビエント プロパティは、設定されていない場合は親コントロールから取得されるコントロール プロパティです。 たとえば、a Button は既定で親Formと同じBackColorになります。 アンビエント プロパティの詳細については、クラスまたはクラスの AmbientProperties 概要を Control 参照してください。

注意 (継承者)

派生クラスのプロパティをオーバーライドする Cursor 場合は、基底クラスの Cursor プロパティを使用して基本実装を拡張します。 それ以外の場合は、すべての実装を指定する必要があります。 プロパティのメソッドとsetメソッドのCursor両方をgetオーバーライドする必要はありません。必要に応じて 1 つだけオーバーライドできます。

適用対象

こちらもご覧ください