C#实验8Windows应用编程
2016-05-25 17:29
363 查看
2 设计如图所示窗体。窗体上有两个按钮:一个显示文本,一个显示图片。单击上面按钮或按下 Alt+B键,可以弹出如图消息框。单击下面按钮也可显示。
5窗体上有一个文本框(多行且带有垂直滚动条)、一个标签(字体颜色红色、自号16)、一个按钮(该按钮被单击时,实现将文本复制至标签)。
6窗体有两个文本框:一个文本框最多输入字符6个;一个文本框输入任何内容都显示*号。再添加一个按钮、两个单选按钮。实现单击按钮后,根据单选按钮,将文本框中内容显示在标签。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("单击了我","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning); } private void button2_Click(object sender, EventArgs e) { MessageBox.Show("单击了我", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } private void button1_KeyDown(object sender, KeyEventArgs e) { if (e.Alt&&e.KeyCode==Keys.B) { MessageBox.Show("单击了我","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning); } } private void Form1_Load(object sender, EventArgs e) { this.KeyPreview = true; } private void button2_KeyDown(object sender, KeyEventArgs e) { if (e.Alt && e.KeyCode == Keys.B) { MessageBox.Show("单击了我", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } } } }
5窗体上有一个文本框(多行且带有垂直滚动条)、一个标签(字体颜色红色、自号16)、一个按钮(该按钮被单击时,实现将文本复制至标签)。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { label1.Text = textBox1.SelectedText; } } }
6窗体有两个文本框:一个文本框最多输入字符6个;一个文本框输入任何内容都显示*号。再添加一个按钮、两个单选按钮。实现单击按钮后,根据单选按钮,将文本框中内容显示在标签。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace frg { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) label1.Text = textBox1.Text; if (radioButton2.Checked) label1.Text = textBox2.Text; } } }
相关文章推荐
- C# Serializable
- 《Head First C#》学习 ---第一个实例中遇到的问题
- Log4net入门使用
- C#实现FTP基本功能源代码
- C#生成缩略图代码
- C# 去除数组重复元素的简单方法
- [C#] 后端post的请求方法
- C# 加载xml文档文件及加载xml字符串
- c#获取中国三级行政区域划分(省市县)以及县级经纬度demo
- C#策略模式(Strategy Pattern) 使用实例
- C# DataTable列名不区分大小写
- c# 导出数据到Excel模板
- C# 中DateTime的各种使用
- c#获取当前日期时间(转)
- C# 串口
- C#图片截取压缩(百分比压缩/大小压缩)实现代码
- C# 读写文件
- C#反射实例应用--------获取程序集信息和通过类名创建类实例
- c# 访问修饰符
- WPF 多线程设计