当前位置:网站首页>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);
}
}
}
边栏推荐
- c#——switch case语句
- [QNX hypervisor 2.2 user manual]9.10 pass
- Blue Bridge Cup: the ninth - "lantern controller"
- Uniapp——拨打电话、发送短信
- [stream] basic knowledge of stream
- The test post changes jobs repeatedly, jumping and jumping, and then it disappears
- 什么是虚函数?
- More than 50 interviews have been summarized, and notes and detailed explanations have been taken from April to June (including core test sites and 6 large factories)
- 【AcWing 327. 玉米田】状压dp
- Thread Foundation
猜你喜欢

树莓派开发继电器控制灯

"Introduction to engineering electromagnetic field" after class exercises with answers

More than 50 interviews have been summarized, and notes and detailed explanations have been taken from April to June (including core test sites and 6 large factories)

《工程电磁场导论》课后习题附答案

Qt官方示例:Fridge Magnets Example(冰箱贴)

Redis实现分布式锁

数据湖(十七):Flink与Iceberg整合DataStream API操作

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

4、 Analysis of solid state disk storage technology (paper)

Thread Foundation
随机推荐
My approval & signature function of conference OA project
MySQL index learning
【类的本质(Objective-C语言中)】
什么是虚函数?
Record of a cross domain problem
蓝桥杯:第九届—“彩灯控制器”
在线问题反馈模块实战(十六):实现查详情功能
[nature of class (in Objective-C language)]
Kubernetes-----介绍
线程基础
Alibaba cloud international email service package purchase process
[acwing 327. corn field] shaped pressure DP
决策树与随机森林学习笔记(1)
[2022 Niuke Game 2 J question link with arithmetic progress] three part set three part / three part extreme value / linear equation fitting least square method
【ACwing 1064 小国王】状压dp
机器人工程是否有红利期
基于OpenCV的轮廓检测(3)
R 笔记 MICE
CAD创建组却没有组合在一起?
数字孪生智慧楼宇可视化平台实现对园区企业、公众服务一体化