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 사용자의 사용 가능한 논리 드라이브로 채웁니다. 또한 이 예제에서는 마우스 포인터가 드롭다운 단추 위에 있을 때 커서가 표시되도록 Cursors.Hand 콤보 상자의 Cursor 속성을 설정합니다. 이 코드를 사용하려면 해당 코드가 Form ComboBox 있어야 합니다.

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 할당하여 마우스 포인터가 컨트롤 위에 있을 때 표시되는 커서를 변경합니다. 일시적으로 애플리케이션 집합에 대해 모든 컨트롤에 대 한 마우스 커서를 변경 하 여 Cursor.Current 속성입니다. 일반적으로 파일을 채울 ComboBox 때 또는 파일을 저장하거나 로드할 때 속성을 대기 커서로 설정합니다Cursor.Current.

Cursor 속성은 앰비언트 속성입니다. 앰비언트 속성은 설정되지 않은 경우 부모 컨트롤에서 검색되는 컨트롤 속성입니다. 예를 들어 a Button 는 기본적으로 부모와 Form 동일합니다BackColor. 앰비언트 속성에 대한 자세한 내용은 클래스 또는 클래스 개요를 Control 참조 AmbientProperties 하세요.

상속자 참고

파생 클래스의 Cursor 속성을 재정의할 때 기본 클래스의 Cursor 속성을 사용하여 기본 구현을 확장합니다. 그렇지 않으면 모든 구현을 제공해야 합니다. 속성의 메서드와 set 메서드를 모두 get 재정의할 필요는 없습니다. 필요한 경우 하나만 재정의 Cursor 할 수 있습니다.

적용 대상

추가 정보