window编程控件的基本使用
来源:互联网 发布:淘宝天猫积分怎么获得 编辑:程序博客网 时间:2024/05/16 01:23
本学期正在学习windows程序设计,学校老师自己编写的教材,课本内容完全是101式的说明,每一步该做什么,会有什么样的结果都很清楚。这样以来,似乎所有的问题都已经解决了,我们只要照着做就行了。其实这样做之能是当时起到方便快速的作用,等脱离开课本自己设计一个小程序的时候就会发现很多小的细节问题。我在几个小地方遇到了点问题,后来虽然功能基本实现了,但个别问题自己仍不满意,希望大家在此能给我指出来程序中的漏洞或代码优化的建议。
这次要做的内容是:
1、设计一个简易的注册界面,效果如图所示。
登录界面
登录后的界面
题型分析:
这次试验的任务还是比较简单的,不涉及数据库的操作,很简单的控件使用,在编码的过程中用到最多的就是label控件,用的相当的顺手。同时,由于windows程序设计很多步骤都可通过鼠标操作来完成,在此我只是简单的解释代码中的一些要注意的地方。防止以后因小问题耽误过多的时间。
第一个界面代码分析:
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 实验1{ public partial class Form1 : Form { public Form1() { InitializeComponent();//面板的初始化 } private void button1_Click(object sender, EventArgs e) { this.Close(); } //验证验证码是否正确 private void button2_Click(object sender, EventArgs e) { if (textBox1YZM.Text == textBox1.Text) { Second sc = new Second(); sc.Show();//正确并显示第二个form } else { label6.Visible = true;//提示标签可见 textBox1YZM.Focus();//光标集中到验证码的开始 textBox1YZM.Clear();//清空当前的验证码 } } private void label5_Click(object sender, EventArgs e) { Random ra = new Random();//随机生成四位数,我在这投机取巧了 textBox1YZM.Text = ra.Next(1000, 9999).ToString(); textBox1YZM.Show(); } int left,right;//这里没能实现,是的label不断从右往左移动 private void label1_Click(object sender, EventArgs e) { timer1.Enabled = true; timer1.Interval = 500; //left = label1.Left; right = label1.Right; } private void timer1_Tick(object sender, EventArgs e) { //left=label1.Left-10; right=label1.Right+10; if (right>this.Width) { right = 0; //left = this.Width; } } }}第二个界面代码分析
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 实验1{ public partial class Form1 : Form { public Form1() { InitializeComponent();//面板的初始化 } private void button1_Click(object sender, EventArgs e) { this.Close(); } //验证验证码是否正确 private void button2_Click(object sender, EventArgs e) { if (textBox1YZM.Text == textBox1.Text) { Second sc = new Second(); sc.Show();//正确并显示第二个form } else { label6.Visible = true;//提示标签可见 textBox1YZM.Focus();//光标集中到验证码的开始 textBox1YZM.Clear();//清空当前的验证码 } } private void label5_Click(object sender, EventArgs e) { Random ra = new Random();//随机生成四位数,我在这投机取巧了 textBox1YZM.Text = ra.Next(1000, 9999).ToString(); textBox1YZM.Show(); } int left,right;//这里没能实现,是的label不断从右往左移动 private void label1_Click(object sender, EventArgs e) { timer1.Enabled = true; timer1.Interval = 500; //left = label1.Left; right = label1.Right; } private void timer1_Tick(object sender, EventArgs e) { //left=label1.Left-10; right=label1.Right+10; if (right>this.Width) { right = 0; //left = this.Width; } } }}反思:
这个实验题虽然非常简单,但也有一些细节要考虑,也是对基本功的考察。比如:随机生成4位整数或字母并输出到指定的地方。滚动条的实现不够好,考察timer控件的理解和使用,验证码要在点击后才会出现等。这些问题我会随时查资料改正,也希望有人给出批评指正。
0 0
- window编程控件的基本使用
- API编程基本控件使用
- API编程基本控件使用
- 控件的基本使用
- kendoUI中window控件的使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- Gallery控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- CStatic控件的基本使用
- C has memset(), the Berkeley UNIX C library has bzero()
- 有效获取scrollWidth clientWidth方法:
- django POST获取字典
- 数据可视化-Python之Matplotlib
- hdu 1874 (spfa)
- window编程控件的基本使用
- 【连载一】漫谈投资机构对企业的估值(一)
- (code jam)Problem A. Store Credit
- 冒泡排序(随机生成10个数排序)
- 【连载八】移动医疗四大入口之大众入口(一)
- 服务端架构中的“网关服务器”
- 比微软kinect更强的视频跟踪算法--TLD跟踪算法介绍
- 【连载二】漫谈投资机构对企业的估值(二)
- 等待队列源码分析