当前位置:网站首页>C WinForm development: how to add pictures to project resources
C WinForm development: how to add pictures to project resources
2022-07-28 03:18:00 【Dusk and starry sky】
C#WinForm Development : How to add pictures to the project resource file (Resources) in
introduction
Operation steps
Application instance
Function extension
introduction
stay C#Winform In development , Sometimes you need to insert some pictures into the control , Common are pictureBox The control of Image attribute . that , How should we add existing pictures to the project resource file ?Operation steps
stay VS 2017 Create a new one in “Windows Form application ” project , Then save two pictures to the desktop . here , Project name: “cyTest”, The name of the picture is “JapaneseBoy” and “WhiteBoard”, At this point the preparatory work is complete .
stay “ Solution explorer ” In the view , double-click “Properities -> Resources.resx” Options :
In the pop-up “Resources.resx” Window , single click " Add resources " After the option “ Inverted triangle ” Icon . then , In the drop-down menu that appears , single click " Add existing file " Options :
Find the path to save the picture , Select two pictures , single click “ open ” button :
“ Solution explorer ” In the view “cyTest” Under the project , Automatic generation “Resources” Folder and two pictures added . thus , Pictures have been successfully added to the project resource file .
Application instance
In the Form For example, insert two pictures in :
stay Form Drag and drop two in pictureBox Control :
Write the following program code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace cyTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Image cyImage1, cyImage2;
private void Form1_Load(object sender, EventArgs e)
{
cyImage1 = Properties.Resources.JapaneseBoy;
pictureBox1.Image = cyImage1;
pictureBox1.Height = cyImage1.Height;
pictureBox1.Width = cyImage1.Width;
pictureBox1.Location = new Point(10, 10);
cyImage2 = Properties.Resources.WhiteBoard;
pictureBox2.Image = cyImage2;
pictureBox2.Height = cyImage2.Height;
pictureBox2.Width = cyImage2.Width;
pictureBox2.Location = new Point(700, 10);
}
}
}
边栏推荐
- Alibaba cloud international email service package purchase process
- 方案分享 | 高手云集 共同探索重口音AI语音识别
- c#——switch case语句
- PCB丝印如何摆?请查收这份手册!
- The digital twin smart building visualization platform realizes the integration of enterprise and public services in the park
- CAD创建组却没有组合在一起?
- QFileDevice、QFile、QSaveFile、QTemporaryFile
- C#设置Textbox控件不可编辑
- 基于c8t6芯片开发RC522模块实现呼吸灯
- 工程地质实习-工程地质 题集
猜你喜欢

Raspberry pie development relay control lamp

基于c8t6芯片开发RC522模块实现呼吸灯

Intelligent industrial design software company Tianfu C round financing of hundreds of millions of yuan

工程地质实习-工程地质 题集
![[stream] basic knowledge of stream](/img/33/0bd85f7e029c81d0c20f463ebb972a.png)
[stream] basic knowledge of stream

Design and practice of unified security authentication for microservice architecture

exness:日本物价上涨收入下降,英镑/日元突破 165

PCB丝印如何摆?请查收这份手册!

ECCV 2022 | open source for generative knowledge distillation of classification, detection and segmentation

Comprehensive comparative study of image denoising
随机推荐
ELS timer
style=“width: ___“ VS width=“___“
Review basic knowledge points of engineering electromagnetic field
工程地质实习-工程地质 题集
Why is it that when logging in, you clearly use the account information already in the database, but still display "user does not exist"?
【类的本质(Objective-C语言中)】
Note that these regions cannot take the NPDP exam in July
Embedded sharing collection 22
C#中关闭窗体的四种方法
Design of the multi live architecture in different places of the king glory mall
四、固态硬盘存储技术的分析(论文)
【下载文件】uniapp开发小程序,下载文件并保存到本地
微服务架构统一安全认证设计与实践
满满干货赶紧进来!!!轻松掌握C语言中的函数
QML使用Layout布局时出现大量<Unknown File>: QML QQuickLayoutAttached: Binding loop detected for property循环绑定警告
Hotel VR panoramic display shooting provides more opportunities for cooperation and negotiation
My approval & signature function of conference OA project
vi命令详解
[stream] parallel stream and sequential stream
在线问题反馈模块实战(十六):实现查详情功能