This is a note about changing the background image of .Net Win Form Application.
Assumption:
- the image resources is embedded.
- you have no idea about the full name of the background image. (tricky ...)
- using System.Reflection;
- using System.IO;
- using System.Drawing;
- Assembly a = Assembly.GetExecutingAssembly();
- string[] resNames = a.GetManifestResourceNames();
- foreach (string s in resNames)
- {
- if (s.EndsWith(".png"))
- {
- Stream imgStream = a.GetManifestResourceStream(s);
- this.BackgroundImage = Bitmap.FromStream(imgStream) as Bitmap;
- break;
- }
- }
Reference
- http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=75
沒有留言:
張貼留言