简体   繁体   中英

How to display background pictures

I simply want to be able to "Insert" background pictures while displaying text in front of it. I'm new to c# so if possible, keep it simple.

使用背景图像属性,或添加图片框/控件,并在其上方放置标签,如果标签在图片控件后面,则将文本标签移到图片框的前面

如果该属性由control公开,则可以尝试从代码后面设置BackGroundImage属性。

control.BackgroundImage = Image.FromFile("C:\\filename.jpg");

I'm guessing you're using the console applications but you cant change the background image on that, if you want to make a program you could try using windows form applications, you can design what you want the user to see and set background images. Change the "BackgroundImage" property, and then import the image you want to use. I'm also new to c# so I know how you feel. Also to impove image quality change it to a bitmap (bmp), its much clearer than a jpeg

To change the background of a form go to the properties of the form and click BackgroundImage

If you want to change it during runtime with code

Make a class called background

class Background
{
    public static string background_file;
}

This is the class

this.BackgroundImage = new Bitmap("file_in_debug_folder");

This will change the background on the current form

Background.background_file = "$this.BackgroundImage-blue.bmp";

This will change the variable in the class to the file location "$this.BackgroundImage-blue.bmp" but this will be changed to the name of your file in the debug folder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM