控件速查表
WinForm 常用控件、事件、枚举速查,方便随时查阅。
1. 常用控件速查
| 控件 |
类名 |
关键属性 |
关键事件 |
| 按钮 |
Button |
Text, BackColor |
Click |
| 标签 |
Label |
Text, TextAlign |
Click |
| 文本框 |
TextBox |
Text, PasswordChar |
TextChanged, KeyPress |
| 图片框 |
PictureBox |
Image, ImageLocation, SizeMode |
Click, MouseEnter/Leave |
| 面板 |
Panel |
BorderStyle |
Paint |
| 分组框 |
GroupBox |
Text(标题) |
— |
| 选项卡 |
TabControl |
TabPages, SelectedTab |
SelectedIndexChanged |
| 复选框 |
CheckBox |
Checked, Text |
CheckedChanged |
| 单选框 |
RadioButton |
Checked, Text |
CheckedChanged |
| 组合框 |
ComboBox |
Items, SelectedIndex, DropDownStyle |
SelectedIndexChanged |
| 列表框 |
ListBox |
Items, SelectedIndex |
SelectedIndexChanged |
| 列表视图 |
ListView |
Items, Columns |
— |
| 数据网格 |
DataGridView |
DataSource |
CellContentClick |
| 定时器 |
Timer |
Interval, Enabled |
Tick |
| 进度条 |
ProgressBar |
Minimum, Maximum, Value |
— |
| 菜单 |
MenuStrip / ToolStrip |
Items |
ItemClicked |
| 状态栏 |
StatusStrip |
Items |
— |
| 图片列表 |
ImageList |
Images |
— |
2. 常用事件速查
| 事件 |
触发时机 |
参数 |
关键属性 |
Click |
鼠标点击 |
EventArgs |
— |
Load |
窗体加载完成 |
EventArgs |
— |
FormClosing |
关闭前(可取消) |
FormClosingEventArgs |
e.Cancel |
FormClosed |
关闭后 |
FormClosedEventArgs |
— |
KeyDown |
按键按下 |
KeyEventArgs |
e.KeyCode |
KeyUp |
按键松开 |
KeyEventArgs |
e.KeyCode |
KeyPress |
字符输入 |
KeyPressEventArgs |
e.KeyChar |
MouseEnter |
鼠标进入 |
EventArgs |
— |
MouseLeave |
鼠标离开 |
EventArgs |
— |
MouseMove |
鼠标移动 |
MouseEventArgs |
e.X, e.Y |
TextChanged |
文本变化 |
EventArgs |
— |
CheckedChanged |
勾选状态变化 |
EventArgs |
— |
SelectedIndexChanged |
选中项变化 |
EventArgs |
— |
Tick |
定时器触发 |
EventArgs |
— |
SizeChanged |
大小变化 |
EventArgs |
— |
3. PictureBox SizeMode 速查
| SizeMode |
效果 |
Normal |
原始大小,超出裁剪 |
StretchImage |
拉伸填充(变形) |
AutoSize |
控件自适应图片大小 |
CenterImage |
居中,超出裁剪 |
Zoom |
等比缩放(推荐) |
4. MessageBox 枚举速查
| 值 |
按钮 |
OK / OKCancel / YesNo / YesNoCancel |
确定 / 确定+取消 / 是+否 / 是+否+取消 |
MessageBoxIcon
| 值 |
图标 |
None / Information / Warning / Error / Question / Asterisk |
无 / 信息 / 警告 / 错误 / 问号 / 星标 |
DialogResult(返回值)
| 值 |
对应 |
OK / Cancel / Yes / No / Abort / Retry / Ignore |
确定 / 取消 / 是 / 否 / 中止 / 重试 / 忽略 |
5. 布局属性速查
| 成员 |
说明 |
Location |
左上角坐标(new Point(x, y)) |
Size |
宽高(new Size(w, h)) |
Dock |
停靠(Top/Bottom/Left/Right/Fill) |
Anchor |
锚定(随父容器缩放) |
AutoSize |
自动调整大小 |
TextAlign |
文字对齐(ContentAlignment) |
TabIndex |
Tab 键切换顺序 |
相关笔记