




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
可视化程序设计实验报告学 号:2143214姓 名:李子厚提交日期:2016-11-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 WindowsFormsApplication1 public partial class Form1 : Form double outValue = 0; bool c = false; string d; bool f = true; int x = 0; int y = 0; public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) caculate(1); private void button2_Click(object sender, EventArgs e) caculate(2); private void button3_Click(object sender, EventArgs e) caculate(3); private void button4_Click(object sender, EventArgs e) caculate(4); private void button5_Click(object sender, EventArgs e) caculate(5); private void button6_Click(object sender, EventArgs e) caculate(6); private void button7_Click(object sender, EventArgs e) caculate(7); private void button8_Click(object sender, EventArgs e) caculate(8); private void button9_Click(object sender, EventArgs e) caculate(9); private void button14_Click(object sender, EventArgs e) caculate(0); private void button10_Click(object sender, EventArgs e) c = true; d = +; textBox1.Text += +; private void button11_Click(object sender, EventArgs e) c = true; d = -; textBox1.Text += -; private void button12_Click(object sender, EventArgs e) switch (d) case +: outValue = x + y; break; case -: outValue = x - y; break; case *: outValue = x * y; break; case /: outValue = x /y; break; textBox1.Text = outValue + ; c = false; f = false; x = 0; y = 0; private void button13_Click(object sender, EventArgs e) textBox1.Text = ; c = false; f = false; x = 0; y = 0; public void caculate(int z) if (f = false) textBox1.Text = ; f = true; if (c = true) textBox1.Text += z; y = 10 * y + z; else textBox1.Text += z; x = 10 * x + z; private void button15_Click(object sender, EventArgs e) if (c = true) y = 0; textBox1.Text = x + d; else x = 0; textBox1.Text = ; private void button17_Click(object sender, EventArgs e) c = true; d = *; textBox1.Text += *; private void button16_Click(object sender, EventArgs e) c = true; d = /; textBox1.Text += /; private void button18_Click(object sender, EventArgs e) /除法功能只能算整除,由于不知道int换成double怎么改所以没能实现【程序截图】实验二 目录与文件【实验内容】做一个简单的记事本,有打开和保存功能【关键代码】using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;namespace test2 public partial class Form1 : Form public Form1() InitializeComponent(); string filename; private void 打开ToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog open = new OpenFileDialog(); filename = open.FileName; open.Filter = txt files (*.txt)|*.txt|All files (*.*)|*.*; open.FilterIndex = 2; open.RestoreDirectory = true; if (open.ShowDialog()=DialogResult.OK) StreamReader reader = new StreamReader(open.FileName, System.Text.Encoding.Default); richTextBox1.Text = reader.ReadToEnd(); reader.Close(); private void 保存ToolStripMenuItem_Click(object sender, EventArgs e) SaveFileDialog save = new SaveFileDialog(); StreamWriter writer; save.Filter = txt files (*.txt)|*.txt|All files (*.*)|*.*; save.FilterIndex = 2; save.RestoreDirectory = true; if (save.ShowDialog() = DialogResult.OK) writer = new StreamWriter(save.FileName); writer.Write(richTextBox1.Text); /写入 writer.Close();/关闭流 【程序截图】实验三 图形图像处理【实验内容】做一个程序,可以读取一个位图并显示,通过点击上下左右按钮,可以调整图片的位置,通过点击放大缩小,可以缩放图片。【关键代码】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 WindowsFormsApplication3 public partial class Form1 : Form Graphics g; int width, height; int x, y; const int per = 5; float rit = 1; public Form1() InitializeComponent(); width = pictureBox1.Width; height = pictureBox1.Height; g = this.pictureBox1.CreateGraphics(); x = y = 0; private void draw() g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); g.TranslateTransform(x, y); g.ScaleTransform(rit, rit); g.DrawImage(pictureBox1.Image, 0, 0, width, height); private void 读取ToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog open = new OpenFileDialog(); open.Filter = image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*; if (open.ShowDialog() = DialogResult.OK) pictureBox1.Image = Image.FromFile(open.FileName); private void pictureBox1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) y = y - per; draw(); private void button2_Click(object sender, EventArgs e) y = y + per; draw(); private void button3_Click(object sender, EventArgs e) x = x - per; draw(); private void button4_Click(object sender, EventArgs e) x = x + per; draw(); private void button5_Click(object sender, EventArgs e) rit = (float)(rit + 0.1); draw(); private void button6_Click(object sender, EventArgs e) if (rit 0) rit = (float)(rit - 0.1); draw(); 【程序截图】 实验四 数据操作【实验内容】制作一个程序,输入一个姓名,点击查询。【关键代码】using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;namespace DBOperate public partial class Form1 : Form SqlDataAdapter adapter; DataTable table; DataSet dataset1; public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) string connStr = Properties.Settings.Default.Database2ConnectionString;/连接字符串 SqlConnection conn = new SqlConnection(connStr);/建立到数据库的连接 adapter = new SqlDataAdapter(select * from Table, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); adapter.InsertCommand = builder.GetInsertCommand(); adapter.DeleteCommand = builder.GetDeleteCommand(); adapter.UpdateCommand = builder.GetUpdateCommand(); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = table; private void button2_Click(object
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025河北邯郸市中煤水文局集团有限公司社会化招聘13人笔试参考题库附带答案详解
- 2025春季福建省港口集团有限责任公司校园招聘219人笔试参考题库附带答案详解
- 卸船机班安全培训制度课件
- 2025年枣庄市重点产业链急需紧缺人才需求(900人)笔试参考题库附带答案详解
- 2025年山东土地资本投资集团有限公司春季社会招聘(10人)笔试参考题库附带答案详解
- 2025年国网河北省电力有限公司高校毕业生招聘(第二批)笔试参考题库附带答案详解
- 2025年合肥市产业投资控股(集团)有限公司校园招聘31人笔试参考题库附带答案详解
- 2025山东济南翠河玫瑰制品有限责任公司招聘7人笔试参考题库附带答案详解
- 2025四川长虹美菱国际区品牌运营中心招聘产品策划岗位4人笔试参考题库附带答案详解
- 2025内蒙古京海煤矸石发电有限责任公司招聘笔试参考题库附带答案详解
- 安全及节能驾驶培训内容课件
- 转基因玉米培训课件
- 3.2《学习成就梦想》教案 -2025-2026学年统编版道德与法治七年级上册
- 造血干细胞移植并发症
- 2025年GCP制度培训测试题(附答案)
- 冷库维保合同(2025版)
- 2025国核示范电站有限责任公司校园招聘笔试历年参考题库附带答案详解
- 2025年护士资格证考试试题(附答案)
- 医院实验室生物安全管理体系文件
- 生活垃圾清运工安全教育培训手册
- 普通诊所污水、污物、粪便处理方案及周边环境情况说明
评论
0/150
提交评论