学习.NET Winform开发 - 展示System.Windows.Forms.Form类的使用
撰写日期:2016/04/20
更新日期:2016/04/22
发布地址:http://www.cnblogs.com/gibbonnet/p/5417191.html
任务场景
基本操作
- 标题
Form.Text
- 大小
Form.Size
- 位置
Form.StartPosition
- 图标
Form.Icon
- 总是最前
Form.TopMost
进阶操作
- 最小化至任务栏
System.Windows.Forms.NotifyIcon
- 文件拖拽动作支持
Form.AllowDrop, DragOver, DragDrop
DemoForm.cs
效果:
编译: csc DemoForm.cs /target:winexe /win32icon:images/title.ico
基本操作源码
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
/**
* DemoForm.cs
- 标题
- 大小
- 位置
- 图标
* csc DemoForm.cs /target:winexe /win32icon:images/title.ico
*/
namespace gibbon.learning.winform
{
public class DemoForm : Form
{
public DemoForm()
{
// set caption
this.Text = "窗口的标题";
// CenterParent, CenterScreen, Manual, WindowsDefaultBounds, WindowsDefaultLocation
this.StartPosition = FormStartPosition.CenterScreen;
// weight, height
this.Size = new Size(500, 600);
// icon
this.Icon = new System.Drawing.Icon("images/Title.ico"