Cursors.Cross Property
.NET Framework 1.1
Gets the crosshair cursor.
[Visual Basic] Public Shared ReadOnly Property Cross As Cursor [C#] public static Cursor Cross {get;} [C++] public: __property static Cursor* get_Cross(); [JScript] public static function get Cross() : Cursor;
Property Value
The Cursor that represents the crosshair cursor.
Example
[Visual Basic, C#] The following code example demonstrates the Hand, Cross and UpArrow members. To run this example paste the following code in a form. Ensure all events are connected to their event-handling methods.
[Visual Basic] Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Private Sub InitializeRadioButtonsAndGroupBox() ' Construct the GroupBox object. Me.GroupBox1 = New GroupBox ' Construct the radio buttons. Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton ' Set the location, tab and text for each radio button ' to a cursor from the Cursors enumeration. Me.RadioButton1.Location = New System.Drawing.Point(24, 24) Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "Help" Me.RadioButton1.Tag = Cursors.Help Me.RadioButton1.TextAlign = ContentAlignment.MiddleCenter Me.RadioButton2.Location = New System.Drawing.Point(24, 56) Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "Up Arrow" Me.RadioButton2.Tag = Cursors.UpArrow Me.RadioButton2.TextAlign = ContentAlignment.MiddleCenter Me.RadioButton3.Location = New System.Drawing.Point(24, 80) Me.RadioButton3.TabIndex = 3 Me.RadioButton3.Text = "Cross" Me.RadioButton3.Tag = Cursors.Cross Me.RadioButton3.TextAlign = ContentAlignment.MiddleCenter ' Add the radio buttons to the GroupBox. Me.GroupBox1.Controls.Add(Me.RadioButton1) Me.GroupBox1.Controls.Add(Me.RadioButton2) Me.GroupBox1.Controls.Add(Me.RadioButton3) ' Set the location of the GroupBox. Me.GroupBox1.Location = New System.Drawing.Point(56, 64) Me.GroupBox1.Size = New System.Drawing.Size(200, 150) ' Set the text that will appear on the GroupBox. Me.GroupBox1.Text = "Choose a Cursor Style" ' ' Add the GroupBox to the form. Me.Controls.Add(Me.GroupBox1) ' End Sub Private Sub RadioButton_CheckedChanged _ (ByVal sender As Object, ByVal e As EventArgs) _ Handles RadioButton1.CheckedChanged, _ RadioButton2.CheckedChanged, RadioButton3.CheckedChanged ' Cast the sender back to a RadioButton object. Dim selectedRadioButton As RadioButton = _ CType(sender, RadioButton) ' If the radio button is in a checked state, then ' change the cursor. If (selectedRadioButton.Checked) Then Cursor = selectedRadioButton.Tag End If End Sub [C#] internal System.Windows.Forms.GroupBox GroupBox1; internal System.Windows.Forms.RadioButton RadioButton1; internal System.Windows.Forms.RadioButton RadioButton2; internal System.Windows.Forms.RadioButton RadioButton3; private void InitializeRadioButtonsAndGroupBox() { // Construct the GroupBox object. this.GroupBox1 = new GroupBox(); // Construct the radio buttons. this.RadioButton1 = new System.Windows.Forms.RadioButton(); this.RadioButton2 = new System.Windows.Forms.RadioButton(); this.RadioButton3 = new System.Windows.Forms.RadioButton(); // Set the location, tab and text for each radio button // to a cursor from the Cursors enumeration. this.RadioButton1.Location = new System.Drawing.Point(24, 24); this.RadioButton1.TabIndex = 0; this.RadioButton1.Text = "Help"; this.RadioButton1.Tag = Cursors.Help; this.RadioButton1.TextAlign = ContentAlignment.MiddleCenter; this.RadioButton2.Location = new System.Drawing.Point(24, 56); this.RadioButton2.TabIndex = 1; this.RadioButton2.Text = "Up Arrow"; this.RadioButton2.Tag = Cursors.UpArrow; this.RadioButton2.TextAlign = ContentAlignment.MiddleCenter; this.RadioButton3.Location = new System.Drawing.Point(24, 80); this.RadioButton3.TabIndex = 3; this.RadioButton3.Text = "Cross"; this.RadioButton3.Tag = Cursors.Cross; this.RadioButton3.TextAlign = ContentAlignment.MiddleCenter; // Add the radio buttons to the GroupBox. this.GroupBox1.Controls.Add(this.RadioButton1); this.GroupBox1.Controls.Add(this.RadioButton2); this.GroupBox1.Controls.Add(this.RadioButton3); // Set the location of the GroupBox. this.GroupBox1.Location = new System.Drawing.Point(56, 64); this.GroupBox1.Size = new System.Drawing.Size(200, 150); // Set the text that will appear on the GroupBox. this.GroupBox1.Text = "Choose a Cursor Style"; // // Add the GroupBox to the form. this.Controls.Add(this.GroupBox1); // } private void RadioButton_CheckedChanged(object sender, EventArgs e) { // Cast the sender back to a RadioButton object. RadioButton selectedRadioButton = (RadioButton) sender; // If the radio button is in a checked state, then // change the cursor. if (selectedRadioButton.Checked) { Cursor = (Cursor)selectedRadioButton.Tag; } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
Cursors Class | Cursors Members | System.Windows.Forms Namespace | Cursor