Load a cursor from a resource in C#

Sometimes it's useful to use a non-standard cursor in a program. This example explains how you can load a cursor from a cursor file included as a project resource.

To add a cursor file to the project's resources, open the Project menu and select Properties. On the Resources tab, open the Add Resource dropdown and select Add Existing File. Select the file and click Open.

Noe use code similar to the following to load the cursor resource at run time.

// Load the cursors from resources.
private void Form1_Load(object sender, EventArgs e)
    pictureBox1.Cursor = new Cursor(new MemoryStream(Properties.Resources.AddLink1));
    pictureBox2.Cursor = new Cursor(new MemoryStream(Properties.Resources._4WAY03));
    pictureBox3.Cursor = new Cursor(new MemoryStream(Properties.Resources.BULLSEYE));

The MemoryStream class is in the System.IO namespace. You can make it easier to use by adding this statement at the top of the file.

using System.IO;



What did you think of this article?

  • No trackbacks exist for this post.
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.


 Email (will not be published)


Your comment is 0 characters limited to 3000 characters.