第五章也仍是主要讲的控件,那些就不详细的写了,我会选取较为重要并对我来讲特殊的点来写。工具
对齐控件:1.选择要对齐的控件。用鼠标将须要对齐的控件进行框起来。2.在Visual Studio菜单中,选择“格式”→“对齐”便可。布局
大部分控件都具备Anchor(锁定)和Dock(停靠)的属性来布局。spa
那么在输入密码是显示的将会是实心圆(●)。也能够自定义字符,只需找到属性PasswordChar将属性改成相应的符号。code
在vs的左边能够找到。orm
在 ToolStrip及ContextMenuStrip和StatusStrip中能够添加图片在属性中能够找到。blog
下拉组合框(ComboBox),复选框(CheckBox),单选按钮(RedioButton)游戏
下拉组合框:为防止文本被随意编辑,能够将下拉组合框的DropDownStyle属性为DropDownList图片
Panel能够将一个窗体中的按钮进行分组,在未分组时,一个窗体中按钮只能选一个,分组后能够进行多选,在vs的左边容器中能够找到。ip
public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { comboBox1.Items.Add("射击游戏");//添加下拉组合框中的选项 comboBox1.Items.Add("益智游戏"); comboBox1.Items.Add("休闲游戏"); comboBox1.SelectedIndex = 0;//默认选项为第一个 } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.Items.Clear();//清除选项内容 if (comboBox1.SelectedIndex==0) { comboBox2.Items.Add ("1"); comboBox2.Items.Add ("2"); comboBox2.Items.Add ("3"); } if (comboBox1.SelectedIndex == 1) { comboBox2.Items.Add("4"); comboBox2.Items.Add("5"); comboBox2.Items.Add("6"); } if (comboBox1.SelectedIndex == 2) { comboBox2.Items.Add("7"); comboBox2.Items.Add("8"); comboBox2.Items.Add("9"); } comboBox2.SelectedIndex = 0; }