Windows程序设计(11页).doc





《Windows程序设计(11页).doc》由会员分享,可在线阅读,更多相关《Windows程序设计(11页).doc(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-Windows程序设计-第 11 页洛阳理工学院实验报告系别计算机与信息工程系班级B100505学号B10050527姓名张勋课程名称C#面向对象程序设计实验日期11.22实验名称Windows程序设计成绩实验目的:练习windows窗体的使用,掌握多种控件的属性,学会应用窗体属性和事件以及代码两种方式操作。实验条件:微机1台、Visual studio 2008实验内容与结果:1. 控制TextBox控件,使它只能输入数字。当按下退格键时,执行退格操作.并且当数据将被清空时,提醒终止删除操作,输入数据。2. 有两个组合框里分别为专业和课程,当专业选定时,课程组合框里的课程数组应属于该专业,
2、通过增加和删除按钮可以把所选的课程添加或删除到列表框,并且在文本框内显示出列表框内的所有课程的总学分数。当没有选课程直接点击添加按钮时:选课程并添加:从列表框内删除:当再次选择“大学物理”时:当更换专业时:3. 比较numericUpDown1.UpButton()和 numericUpDown1.Value+=numericUpDown1.Increment;的区别,这里把文本框数值的上限设为20,下限设为0,增值为1.当达到上限时, numericUpDown1.UpButton()执行正常,而另一句却出现错误,语句无法执行添加快捷菜单,在窗口菜单中有大中小三个菜单项,分别控制着窗口的大小
3、,单击右键弹出快捷菜单使快捷菜单的功能与窗口菜单相同。窗口菜单操作下:快捷菜单操作下:附加窗体的代码:(部分功能在属性中执行了,故在代码中没有设置)1. 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 p7_4 public partial class Form1 : For
4、m public Form1() InitializeComponent(); private void textBox1_KeyPress(object sender, KeyPressEventArgs e) if (e.KeyChar = 48 & e.KeyChar = 57) ; else if (e.KeyChar = 8) textBox1.Text.Remove(textBox1.Text.Length - 1); if (textBox1.Text.Length = 1) MessageBox.Show(请输入数据!, 警告, MessageBoxButtons.OK, Me
5、ssageBoxIcon.Error); else e.Handled = true; private void Form1_Load(object sender, EventArgs e) 2. 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 p7_5 public par
6、tial class Form1 : Form private int totalHours = 0; public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) string course = new string4 数学, 英语, 计算机, 电子工程 ; for (int i = 0; i 4; i+) comboBox1.Items.Add(coursei); textBox1.Text = 0; private void comboBox1_TextChanged(o
7、bject sender, EventArgs e) comboBox2.Items.Clear(); listBox1.Items.Clear(); textBox1.Text = 0; Course math = new Course4 new Course(英语, 50), new Course(高等数学, 60), new Course(数理统计, 35), new Course(计算机应用基础, 40) ; Course English = new Course2 new Course(英语, 50), new Course(计算机应用基础, 40) ; Course Compute
8、r = new Course5 new Course(英语, 50), new Course(高等数学, 60), new Course(大学物理, 40), new Course(计算机应用基础, 40), new Course(计算机语言程序设计, 45) ; Course Electronic_Engineer = new Course5 new Course(英语, 50), new Course(高等数学, 60), new Course(大学物理, 40), new Course(计算机应用基础, 40), new Course(电子电工, 45) ; string s = com
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Windows 程序设计 11

限制150内