Click here to Skip to main content
15,909,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
I created a project in Visual Studio 2008. Then I put a file called "arrow.cur" into "Resources.resx". I want to use arrow.cur in
C#
Form1_Load(object sender, EventArgs e)
method. How can I show this cursor?
I tried to write code like this, but it didn't work:
private void Form1_Load(object sender, EventArgs e)
{
    byte[] cur = global::Demo.Properties.Resources.arrow;
    MemoryStream stream = new MemoryStream();
    stream.Write(cur, 0, cur.Length);
    Cursor cursor = new Cursor(stream);
    this.Cursor = cursor;
}

If you know the solution, please help me.
Thanks!
Posted
Updated 15-Nov-10 9:20am
v4

This code worked for me:
C#
private static Cursor ReadFromResource(byte[] res)
{
    MemoryStream stream = new MemoryStream(res);
    Cursor result = new Cursor(stream);
    stream.Close(); // important
}

And then,
this.Cursor = ReadFromResource(Test.Properties.Resources.Arrow);
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900