C#实验8Windows应用编程
来源:互联网 发布:eve欧服网络问题 编辑:程序博客网 时间:2024/05/22 03:49
2 设计如图所示窗体。窗体上有两个按钮:一个显示文本,一个显示图片。单击上面按钮或按下 Alt+B键,可以弹出如图消息框。单击下面按钮也可显示。
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; } }}
0 0
- C#实验8Windows应用编程
- Windows应用高级编程C#编程篇
- C#编程基础 实验(8) (4)
- 《windows编程实验记录》
- windows编程实验二
- Windows编程实验4
- windows编程实验四
- 实验4 Windows界面编程
- Windows编程实验第一课
- Windows编程实验第一课
- windows编程实验1代码
- windows编程实验二 1
- Windows编程实验第二课
- Windows编程实验第三课
- Windows编程最后一次实验
- 第一次C#实验--编程分析
- C# Windows Form编程
- c# windows编程基础
- 关于 重入
- 多态(C++版)
- android电池管理系统
- 实现WIN CE下截屏并且保存到文件
- List Leaves (25分)
- C#实验8Windows应用编程
- 【iOS小笔记】iOS工程报错及解决办法整理
- 【下载】《大教堂和市集》:开放源代码运动的《圣经》
- MessageBox、::MessageBox 、AfxMessageBox三者的区别
- jsp中文乱码问题
- 从学习export命令理解到的Shell环境和变量生存期
- io_service用法
- 我的Linux书架
- HTML解析原理