电子商务马志伟C#实验报告
来源:互联网 发布:mysql limit where优化 编辑:程序博客网 时间:2024/06/09 14:28
河北科技大学理工学院
电子商务马志伟C#语言课程设计
专 业 班 级 电子商务L112
学 生 姓 名 马志伟
学 号 11L0207207
指 导 教 师王玉恒陈军霞李庆恒 董绍辉
2013 年 2 月
目录
题目1:ListBox使用示例………………………………………………1
题目2:Timer使用示例…………………………………………………3
题目3:HscrollBar使用示例…………………………………………5
题目4:MessageBox使用示例…………………………………………8
题目1:ListBox
用户从列表框中选择月份,同时在文本框中显示选择的月份,单击按钮后判断显示该月份属于哪个季节。
各控件属性设置
控件类型
原控件名
属性
设置结果
Form
Form1
Name
frmMonth
Text
Month
TextBox
TextBox1
Name
txtMonth
ReadOnly
True
TextBox2
Name
txtSeason
ReadOnly
True
ListBox
ListBox1
Name
lstMonth
Items
一次添加“1”,“2”,“3”,“4”,“5”,“6”,“7“,”8“,”9“,”10“,”11“,”12“
Button
Button1
Name
btnSeason
Text
对应季节
代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceListBox
{
publicpartial class frmMonth : Form
{
public frmMonth()
{
InitializeComponent();
}
privatevoid lstMonth_SelectedIndexChanged(object sender,EventArgse)
{
txtMonth.Text = lstMonth.SelectedItem.ToString();
}
privatevoidbtnSeason_Click(object sender,EventArgs e)
{
switch(lstMonth.SelectedIndex)
{
case0:
case1:
case2:
txtSeason.Text ="您所选择的月份是春季";
break;
case3:
case4:
case5:
txtSeason.Text = "您所选择的月份是夏季";
break;
case6:
case7:
case8:
txtSeason.Text = "您所选择的月份是秋季";
break;
default:
txtSeason.Text = "您所选择的月份是冬季";
break;
}
}
}
}
运行结果:
题目2:Timer
设计一个时钟程序,将系统时间显示在文本框中,要求每秒钟更新一次时间。
各控件属性设置
控件类型
控件名称
属性
设置结果
Form
Form1
Name
frmShowTime
Text
Timer
Label
Label1
Text
当前时间:
TextBox
TextBox1
Name
txtShowTime
Timer
Timer1
Name
tmrShowTime
Interval
1000(即1秒)
代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsApplication3
{
publicpartial class frmShowTime : Form
{
public frmShowTime()
{
InitializeComponent();
}
privatevoidlabel1_Click(object sender,EventArgs e)
{
}
privatevoidfrmShowTime_Load(object sender,EventArgs e)
{
tmrShowTime.Enabled = true;
}
privatevoidtmrShowTime_Tick(object sender,EventArgs e)
{
txtShowTime.Text = System.DateTime.Now.ToString();
}
}
}
运行结果:
题目3:HscrollBar
设计一个调色板,用户单击三个滚动条两端的箭头按钮、直接拖动滚动条的滑块或单击滚动条滑竿时,均可以调整FormArgb()方法中对应的颜色值,从而使“颜色效果”区域中显示不同颜色。
各控件属性设置
控件类型
控件名称
属性
设置结果
From
From1
Text
frmColor
Text
HScrollBar
GroupBox
GroupBox1
Text
颜色效果
Label
Label1
Name
lblShowColor
Text
清空
AutoSize
False
BorderStyle
Fixed3D
Size
大致略小于框架控件
Label2
Name
lblRed
Text
红色值:
Label3
Name
lblGreen
Text
绿色值:
Label4
Name
lblBlue
Text
蓝色值:
HScrollBar
HScrollBar1
Name
hsRed
Minimum
0
Maximum
225
SmallChange
1
LargeChange
1
HScrollBar2
Name
hsGreen
Minimum
0
Maximum
225
SmallChange
1
LargeChange
1
HScrollBar3
Name
hsBlue
Minimum
0
Maximum
225
SmallChange
1
LargeChange
1
代码如下:usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceHScrollBar
{
publicpartial class frmCorlor : Form
{
publicfrmCorlor()
{
InitializeComponent();
}
privatevoidfrmColor_Load(object sender,EventArgs e)
{
lblRed.Text = "红色值:" +hsbRed.Value.ToString();
lblGreen.Text = "绿色值:" +hsbGreen.Value.ToString();
lblBlue.Text = "蓝色值:"+hsbBlue.Value.ToString();
changecolor();
}
void changecolor()
{
Color color =newColor();
color = System.Drawing.Color.FromArgb
(hsbRed.Value, hsbGreen.Value, hsbBlue.Value);
lblShowColor.BackColor = color;
}
privatevoidhsbRed_Scroll(object sender,ScrollEventArgs e)
{
lblRed.Text = "红色值:" +hsbRed.Value.ToString();
changecolor();
}
privatevoidhsbGreen_Scroll(object sender,ScrollEventArgs e)
{
lblGreen.Text = "绿色值:" +hsbGreen.Value.ToString();
changecolor();
}
privatevoidhsbBlue_Scroll(object sender,ScrollEventArgs e)
{
lblBlue.Text = "蓝色值:" +hsbBlue.Value.ToString();
changecolor();
}
}
}
题目4:MessageBox
在文本框中输入圆的半径和圆柱的高,然后再判断输入的数值是否正确,若输入的数值大于0,则计算圆柱的体积并使用消息框输出,若输入的数值小于0,则使用消息框询问是否重新输入,如果选择“是”,则清空文本框,等待重新输入,否则不作任何处理。
各控件属性设置
控件类型
控件名称
属性
设置结果
Form
Form1
Name
frmMessageBox
Text
UseMessageBox
Label
Label1
Text
输入圆的半径:
Label2
Text
输入圆柱的高:
TextBox
TextBox1
Name
txtRadius
TextBox2
Name
txtgao
Button
Button1
Name
btnShowResult
Text
查看结果
代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceUseMassageBox
{
publicpartial class frmMessageBox :Form
{
public frmMessageBox()
{
InitializeComponent();
}
privatevoidbutton1_Click(object sender,EventArgs e)
{
float radius;
float gao;
float area;
constfloat PI = 3.14F;
gao = float.Parse(txtgao.Text);
radius = float.Parse(txtRadius.Text);
if (radius > 0 & gao > 0)
{
area = PI * radius * radius *gao;
MessageBox.Show("圆柱的体积为:" + area.ToString(),"输出结果");
}
else
{
if(MessageBox.Show("输入的数字有误,重新输入?","输入错误",
MessageBoxButtons.YesNo,MessageBoxIcon.Question) ==DialogResult.Yes)
{
txtRadius.Text = "";
txtgao.Text = "";
txtRadius.Focus();
}
}
}
}
}
运行结果:
- 电子商务马志伟C#实验报告
- c#实验报告模拟发牌程序
- C#控制台练习多肽实验报告
- b2b电子商务研究报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 实验报告
- 国内电子商务网站分析报告
- shoelace源代码分析之bootlace
- CodeForces Good Bye 2013
- 服务器-apache-common-httpclient测试
- HTML5实战与剖析之自定义数据属性(dataset)
- php xmlrpc的简单实用
- 电子商务马志伟C#实验报告
- js 读取cookie 添加 删除
- 加载性能优化ViewHolder
- Outdoor Light Scattering From Intel
- 计算阶乘n!末尾所含0的个数
- cookie.js js操作cookie
- Spring与Struts配置文件笔记
- php禁止浏览器直接访问
- SMBIOS介绍(1):概述