다음을 통해 공유


Control.Cursor 속성

마우스 포인터가 컨트롤 위에 있을 때 표시되는 커서를 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Overridable Property Cursor As Cursor
‘사용 방법
Dim instance As Control
Dim value As Cursor

value = instance.Cursor

instance.Cursor = value
public virtual Cursor Cursor { get; set; }
public:
virtual property Cursor^ Cursor {
    Cursor^ get ();
    void set (Cursor^ value);
}
/** @property */
public Cursor get_Cursor ()

/** @property */
public void set_Cursor (Cursor value)
public function get Cursor () : Cursor

public function set Cursor (value : Cursor)

속성 값

마우스 포인터가 컨트롤 위에 있을 때 표시되는 커서를 나타내는 Cursor입니다.

설명

컨트롤의 Cursor 속성에 Cursor를 할당하여 마우스 포인터가 컨트롤 위로 이동될 때 표시되는 커서를 변경합니다. 응용 프로그램에 있는 모든 컨트롤의 마우스 커서를 일시적으로 변경하려면 Cursor.Current 속성을 설정합니다. 일반적으로 ComboBox를 채우거나 파일을 저장 또는 로드할 때는 Cursor.Current 속성을 WaitCursor로 설정합니다.

Cursor 속성은 앰비언트 속성입니다. 앰비언트 속성은 컨트롤 속성으로, 설정되지 않은 경우에는 부모 컨트롤에서 해당 속성을 가져옵니다. 예를 들어, Button은 기본적으로 자신의 부모 Form과 같은 BackColor를 갖습니다. 앰비언트 속성에 대한 자세한 내용은 AmbientProperties 클래스 또는 Control 클래스 개요를 참조하십시오.

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

예제

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

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
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:
   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.set_Cursor(Cursors.get_Hand());
    // Fill the combo box with all the logical 
    // drives available to the user.
    try {
        for (int iCtr = 0; iCtr < Environment.GetLogicalDrives().
            get_Length(); iCtr++) {
            String logicalDrive = Environment.GetLogicalDrives()[iCtr];
            comboBox1.get_Items().Add(logicalDrive);
        }
    }
    catch (System.Exception ex) {
        MessageBox.Show(ex.get_Message());
    }
} //Form1_Load

.NET Framework 보안

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
Cursor
Cursors