Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I convert a Cursor class to a cursor (.cur) file?

protected void WriteCursorToFile( Cursor cursor, string fileName ) 
{ 
  TypeConverter converter = TypeDescriptor.GetConverter( typeof( Cursor ) );
  byte[] blob = converter.ConvertTo( cursor, typeof( byte[] ) ) as byte[]; 
  if ( blob == null ) 
  {
    MessageBox.Show( "Unable to convert Cursor to byte[]" ); 
    return;
  }
  FileStream fileStream = new FileStream( fileName, FileMode.Create ); 
  fileStream.Write( blob, 0, blob.Length ); 
  fileStream.Flush(); 
  fileStream.Close(); 
}

Contributed from George Shepherd's Windows Forms FAQ