Export (0) Print
Expand All

Cursor Constructor (Stream)

Initializes a new instance of the Cursor class from the specified data stream.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public Cursor(
	Stream stream


Type: System.IO.Stream

The data stream to load the Cursor from.

The data stream specified by stream must contain a cursor (.cur) file.


Animated cursors (.ani files) are not supported by the Cursor class.

The following code example loads a cursor from a Stream created by the OpenFile method of an OpenFileDialog. When the method is called, an OpenFileDialog is displayed to the user and when a. CUR file is selected and the dialog closed, the file is opened and the Stream returned is used to create a Cursor.

private void SetCursor()
   // Display an OpenFileDialog so the user can select a cursor.
   OpenFileDialog openFileDialog1 = new OpenFileDialog();
   openFileDialog1.Filter = "Cursor Files|*.cur";
   openFileDialog1.Title = "Select a Cursor File";

   // If a .cur file was selected, open it. 
   if(openFileDialog1.FileName != "")
      // Assign the cursor in the stream to the form's Cursor property. 
      this.Cursor = new Cursor(openFileDialog1.OpenFile());

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft