zoukankan
html css js c++ java
C# Windows Form programming 系列之二
[assembly: System.Reflection.AssemblyVersion(
"
1.2
"
)]
namespace
MyNamespace
{
using
System;
using
System.Drawing;
using
System.Windows.Forms;
public
class
MyForm : Form
{
private
Button btnLoad;
private
PictureBox pboxPhoto;
public
MyForm()
{
this
.Text
=
"
Wentao's C# Form
"
;
//
Set the form's minimum size
this
.MinimumSize
=
new
Size(
200
,
200
);
//
Create and configurate the Button
btnLoad
=
new
Button();
btnLoad.Text
=
"
&Load
"
;
btnLoad.Left
=
10
;
btnLoad.Top
=
10
;
btnLoad.Click
+=
new
System.EventHandler(
this
.OnLoadClick);
btnLoad.Anchor
=
AnchorStyles.Top
|
AnchorStyles.Left;
//
Create and configurate the PictureBox
pboxPhoto
=
new
PictureBox();
pboxPhoto.BorderStyle
=
System.Windows.Forms.BorderStyle.Fixed3D;
pboxPhoto.Width
=
this
.Width
/
2
;
pboxPhoto.Height
=
this
.Height
/
2
;
pboxPhoto.Left
=
(
this
.Width
-
pboxPhoto.Width)
/
2
;
pboxPhoto.Top
=
(
this
.Height
-
pboxPhoto.Height)
/
2
;
pboxPhoto.SizeMode
=
PictureBoxSizeMode.StretchImage;
pboxPhoto.Dock
=
DockStyle.Fill;
//
Support for picturebox resize operation
//
pboxPhoto.Anchor = AnchorStyles.Top | AnchorStyles.Bottom
//
| AnchorStyles.Left | AnchorStyles.Right;
//
Add our new controls to the Form
this
.Controls.Add(btnLoad);
this
.Controls.Add(pboxPhoto);
}
private
void
OnLoadClick(
object
sender, System.EventArgs e)
{
OpenFileDialog dlg
=
new
OpenFileDialog();
dlg.Title
=
"
Open Photo
"
;
dlg.Filter
=
"
jpg files(*.jpg) | *.jpg|All files(*.*)|*.*
"
;
if
(dlg.ShowDialog()
==
DialogResult.OK)
{
pboxPhoto.Image
=
new
Bitmap(dlg.OpenFile());
}
dlg.Dispose();
}
public
static
void
Main()
{
Application.Run(
new
MyForm());
}
}
}
查看全文
相关阅读:
了解HDD或SDD磁盘的健康状态
修复丢失的打开方式
Invoke-WebRequest : 请求被中止: 未能创建 SSL/TLS 安全通道。
绕过禁止未登陆用户访问
debug
更新已有数据
编码格式(乱码)
ajax
Http
科学的管理和规范标准
原文地址:https://www.cnblogs.com/SunWentao/p/1245828.html
最新文章
SQL Server中行列转换【转】
【转】EasyUI Accordion下的Panel面板初始化时全部折叠
流水报表 SQL累加
【转】利用json获取字符出现次数的代码
string.Format
编码UTF-8的不可映射字符 maven3.2
未与 -source 1.6 一起设置引导类路径
Java和Tomcat类加载机制
没有处理程序要使用以下任何注释:javax.persistence.PersistenceContext
File not found: MANIFEST.MF
热门文章
Aspect Oriented
AspectJ代码修改
nginx反向代理配置
[emerg] the size 10485760 of shared memory zone “tmpcache” conflicts with already declared size 0 in
sql server 使用公共表表达式(CTE)递归
查看登陆事件
使用invoke-webrequest下载文件
获取下载文件的大小
Iexplore常用参数
以指定宽度分割文本
Copyright © 2011-2022 走看看