要求:新建一个windows应用程序,在一个formexcel窗体控件中用分组控件将各个题分开。 效果图截图如下。然后安装部

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
内向70%+外向30%
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
各控件要求如下表:
listBoxYueShouRu
comboBoxZhengJianLeiXing
groupBoxUser
labelYueShouRu
labelShouRu
labelZhengJianLeiXing
labelZhengJian
3)双击窗体空白处进入代码编辑窗口,输入如下代码:
private void
Form1_Load(object sender, EventArgs e)
&&& //ListBox初始化
&&& listBoxYueShouRu.Items.Add("100以下");
&&& listBoxYueShouRu.Items.Add("1000-2000");
&&& listBoxYueShouRu.Items.Add("2001-3000");
&&& listBoxYueShouRu.Items.Add("3000-4000");
&&& listBoxYueShouRu.Items.Add("4000-5000");
&&& listBoxYueShouRu.Items.Add("5000-6000");
&&& listBoxYueShouRu.Items.Add("6000-7000");
&&& listBoxYueShouRu.Items.Add("6000-7000");
&&& listBoxYueShouRu.Items.Add("7000-8000");
&&& listBoxYueShouRu.Items.Add("8000-9000");
&&& listBoxYueShouRu.Items.Add("9000-10000");
&&& listBoxYueShouRu.Items.Add("10000以上");
&&& //ComboBox初始化
&&& comboBoxZhengJianLeiXing.Items.Add("身份证");
&&& comboBoxZhengJianLeiXing.Items.Add("学生证");
&&& comboBoxZhengJianLeiXing.Items.Add("教师证");
&&& comboBoxZhengJianLeiXing.Items.Add("军人证");
&&& comboBoxZhengJianLeiXing.Items.Add("护照");
4)分别双击ListBox和ComboBox,分别输入如下代码:
private void
listBoxYueShouRu_SelectedIndexChanged(object sender, EventArgs e)
&&& labelShouRu.Text = listBoxYueShouRu.SelectedItem.ToString();
private void
comboBoxZhengJianLeiXing_SelectedIndexChanged(object sender, EventArgs e)
&&& labelZhengJian.Text =
comboBoxZhengJianLeiXing.SelectedItem.ToString();
5)运行效果如下图:
&5、列表视图
1)新建一个名为E31的窗体,Text改为“列表视图”
2)在窗体中中添加五个控件,添加完成后的效果如下图:
各控件要求如下表:
3)双击窗体空白处进入代码编辑窗口,输入如下代码:
private void Form1_Load(object sender, EventArgs e)
&&& listViewanimal.Items.Add("大象",0);
&&& listViewanimal.Items.Add("狗", 1);
&&& listViewanimal.Items.Add("猫",2);
&&& listViewanimal.Items.Add("青蛙",3);
&&& listViewanimal.Items.Add("蛇",4);
&&& listViewanimal.Items.Add("兔子",5);
&&& listViewanimal.Items.Add("乌龟",6);
4)双击ListView控件,输入如下代码:
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
&&& labelAnimal.Text = listViewanimal.FocusedItem.T
5)运行效果如下图:
1)新建一个名为E32的窗体,Text改为“树视图”,Size设为“400,500”
2)添加一个TreeView控件,将Size属性改为“390,470”,并将Anchor属性改为“Top, Bottom, Left, Right”
3)添加一个ImageList控件,为其添加“我的电脑”,“磁盘驱动器”,“文件夹”,“打开的文件夹”四个图标(通过Images属性实现)
4)将TreeView的ImageList属性置为imageList1,使两者相关联
5)打开TreeView属性Nodes的树节点编辑器,添加一个根,将标签改为“我的电脑”,在“ImageKey”和“SelectedImageKey”中选择相应图标。
6)完成后的效果如下图:
7)双击TreeView,输入如下图标:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
&&& if (e.Node.Text.ToString() != "我的电脑")
&&&&&&& EnumDirectories(e.Node);
&&&&&&& EnumDrives(e.Node);
以上的AfterSelect事件中用到EnumDirectories和EnumDrives两个方法,其中还用到了System.IO下的Directory,需在头部添加“using System.IO;”。两个方法的实现代码如下:
private void EnumDrives(TreeNode ParentNode)
&&& if(ParentNode.Nodes.Count==0)
&&&&&&& foreach(string drive in Directory.GetLogicalDrives())
&&&&&&&&&&& treeView1.SelectedNode=ParentN
&&&&&&&&&&& TreeNode TempNode=new TreeNode();
&&&&&&&&&&& TempNode.Text=drive.Substring(0,drive.Length-1);
&&&&&&&&&&& TempNode.Tag=
&&&&&&&&&&& TempNode.ImageIndex=1;
&&&&&&&&&&& TempNode.SelectedImageIndex = 1;
&&&&&&&&&&& treeView1.SelectedNode.Nodes.Add(TempNode);
&&&&& &&&&&&treeView1.SelectedNode.Nodes[treeView1.SelectedNode.Nodes.Count - 1].EnsureVisible();
private void EnumDirectories(TreeNode ParentNode)
&&& treeView1.SelectedNode = ParentN
&&& string DirectoryPath = ParentNode.Tag.ToString();
&&& if (ParentNode.Nodes.Count == 0)
&&&&&&& if (DirectoryPath.Substring(DirectoryPath.Length - 1) != @"\")
&&&&&&&&&&& DirectoryPath += @"\";
&&&&&&& try
&&&&&&&&&&& foreach (string directory in Directory.GetDirectories(DirectoryPath))
&&&&&&&&&&& {
&&&&&&&&&&&&&&& TreeNode TempNode = new TreeNode();
&&&&&&&&&&&&&&& TempNode.Text = directory.Substring(directory.LastIndexOf(@"\") + 1);
&&&&&&&&&&&&&&& TempNode.Tag =
&&&&&&&&&&&&&&& TempNode.ImageIndex = 3;
&&&&&&&&&&&&&&& TempNode.SelectedImageIndex = 2;
&&&&&&&&&&&&&&& treeView1.SelectedNode.Nodes.Add(TempNode);
&&&&&&&&&&&&&&& treeView1.SelectedNode.Nodes[treeView1.SelectedNode.Nodes.Count - 1].EnsureVisible();
&&&&&&&&&&& }
&&&&&&& catch (Exception)
8)运行效果如下图:
7、Timer控件
1)新建一个名为E32的窗体,Text改为“Timer控件”
2)添加一个Timer控件,设置其Interval属性为10,表示每隔10毫秒发生一个Tick事件
3)添加两个Button控件,Text属性分别改为:“开始/继续”(表示开始计时或停止后继续开始计时)和“停止/清零”(表示停止计时或在计时停止时将计时器清零),
4)添加一GroupBox控件,Text改为“计时器”
5)在GroupBox中添加三个Label控件用于显示分钟数、秒数及精确到0.01毫秒的小数,Name分别设为labelFen,labelMiao,labelHaomiao,Text都设为0;再添加两个Label控件,Text都设为“:”,用于分隔前三个控件
6)双击“开始/继续”按钮,添加如下代码:
private void button1_Click(object sender, EventArgs e)
&&& timer1.Enabled =
7)双击“停止/清零”按钮,添加如下代码:
private void button2_Click(object sender, EventArgs e)
&&& if (timer1.Enabled == true)
&&&&&&& timer1.Enabled =
&&&&&&& labelFen.Text = "0";
&&&&&&& labelMiao.Text = "0";
&&&&&&& labelHaomiao.Text = "0";
8)双击Timer控件,添加如下代码:
private void timer1_Tick(object sender, EventArgs e)
&&& int min = Int32.Parse(labelFen.Text);
&&& int sec = Int32.Parse(labelMiao.Text);
&&& int fra = Int32.Parse(labelHaomiao.Text);
&&& fra++;
&&& //分钟数
&&& if (sec == 60)
&&&&&&& min++;
&&&&&&& labelFen.Text = min.ToString();
&&&&&&& labelMiao.Text = "0";
&&&&&&& if (min == 100)
&&&&&&&&&&& timer1.Enabled =
&&&&&&&&&&& MessageBox.Show("计时器已达到上限", "提示");
&&&&&&&&&&&
&&& //秒数
&&& if (fra == 100)
&&&&&&& sec++;
&&&&&&& labelMiao.Text = sec.ToString();
&&& //秒数小数位
&&& fra = fra % 100;
&&& labelHaomiao.Text = fra.ToString();
9)运行效果如下图:
8、时钟控件和日历控件
1)新建一个名为E35的窗体,Text改为“日历”,Name改为“FormCalendar”,Size改为“300,320”
2)添加以下几个控件并进行相应设置:
效果如下:
3)双击各相应控件,添加对应代码,完整代码如下:
using System.Collections.G
using System.Da
using System.D
using System.L
using System.T
using System.Windows.F
namespace E35
&&& public partial class FormCalendar : Form
&&&&&&& public FormCalendar()
&&&&&&&&&&& InitializeComponent();
&&&&&&& private void timer1_Tick(object sender, EventArgs e)
&&&&&&&&&&& dateTimePickerCalendar.Value = dateTimePickerCalendar.Value.AddSeconds(trackBarCalendar.Value * 60 + 1);
&&&&&&&&&&& monthCalendarCalendar.TodayDate = dateTimePickerCalendar.V
&&&&&&& private void FormCalendar_Load(object sender, EventArgs e)
&&&&&&&&&&& dateTimePickerCalendar.Value = DateTime.N
&&&&&&&&&&& monthCalendarCalendar.TodayDate = DateTime.N
&&&&&&& private void trackBar1_ValueChanged(object sender, EventArgs e)
&&&&&&&&&&& if (trackBarCalendar.Value & 0)
&&&&&&&&&&&&&&& timerCalendar.Interval = 10;
&&&&&&&&&&& else
&&&&&&&&&&&&&&& timerCalendar.Interval = 1000;
&&&&&&& private void button1_Click(object sender, EventArgs e)
&&&&&&&&&&& buttonStop.ForeColor = buttonReset.ForeC
&&&&&&&&&&& buttonStop.Enabled =
&&&&&&&&&&& timerCalendar.Enabled =
&&&&&&&&&&& buttonRun.ForeColor = Color.G
&&&&&&&&&&& buttonRun.Enabled =
&&&&&&& private void button2_Click(object sender, EventArgs e)
&&&&&&&&&&& buttonRun.ForeColor = buttonReset.ForeC
&&&&&&&&&&& buttonRun.Enabled =
&&&&&&&&&&& timerCalendar.Enabled =
&&&&&&&&&&& buttonStop.ForeColor = Color.G
&&&&&&&&&&& buttonStop.Enabled =
&&&&&&& private void button3_Click(object sender, EventArgs e)
&&&&&&&&&&& trackBarCalendar.Value = 0;
&&&&&&&&&&& dateTimePickerCalendar.ResetText();
4)运行效果如下图:
9、MDI(多文档)窗口
1)新建一个名为E36的窗体,Text改为“多文档窗口”,Name改为“FormMain”,WindowState改为“Maximized”
2)添加一个MenuStrip控件,Name改为“menuStripMainMenu”,建立如下菜单结构:
菜单━━━文件━━━新建   ┃   ┗━━关闭   ┗━排列━━━层叠       ┃━━垂直       ┗━━水平
3)双击各菜单项,添加对应代码,完整代码如下:
using System.Collections.G
using System.Da
using System.D
using System.L
using System.T
using System.Windows.F
namespace E36
&&& public partial class FormMain : Form
&&&&&&& private static int FormCount = 0;//设置一个私有整形变量,记录新建窗口编号
&&&&&&& public FormMain()
&&&&&&&&&&& InitializeComponent();
&&&&&&& private void toolStripMenuItem1_Click(object sender, EventArgs e)
&&&&&&& private void Form1_Load(object sender, EventArgs e)
&&&&&&& private void 新建NToolStripMenuItem_Click(object sender, EventArgs e)
&&&&&&&&&&& Form temp = new Form();
&&&&&&&&&&& temp.MdiParent =
&&&&&&&&&&& temp.Text = "窗口#" + FormCount.ToString();
&&&&&&&&&&& FormCount++;
&&&&&&&&&&& temp.Show();
&&&&&&& private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)
&&&&&&&&&&& this.Close();
&&&&&&& private void 水平HToolStripMenuItem_Click(object sender, EventArgs e)
&&&&&&&&&&& this.LayoutMdi(MdiLayout.Cascade);
&&&&&&& private void 垂直VToolStripMenuItem_Click(object sender, EventArgs e)
&&&&&&&&&&& this.LayoutMdi(MdiLayout.TileHorizontal);
&&&&&&& private void 水平HToolStripMenuItem1_Click(object sender, EventArgs e)
&&&&&&&&&&& this.LayoutMdi(MdiLayout.TileVertical);
//说明:利用系统提供的LayoutMdi方法来排列窗口
4)运行效果如下图:
五、实验要求:
1、填写完整的实验报告。
2、总结Microsoft Visual C# 2008 Windows窗体应用程序设计的一般步骤。
3、记录上机过程中所出现的相关英文信息如菜单项名称、错误提示等,查出其中文含义,并写在实验报告后面。
 Visual C# 2008 Windows窗体应用程序设计细节。
阅读(13678)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_087075',
blogTitle:'实验四:C# Windows窗体应用程序设计练习',
blogAbstract:'一、实验名称:
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}WinForms笔试题_模拟考试_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
WinForms笔试题_模拟考试
上传于||暂无简介
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩4页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢以下试题来自:
问答题请根据以下各小题的要求设计Visual Basic应用程序(包括界面和代码)。
1.在名称为Form1的窗体上放置一个名称为Drive1的DriveListBox控件,一个名称为Dir1的DirListBox控件和一个名称为File1的FileListBox控件。程序运行时,可以对系统中的文件进行浏览;当双击File1中的文件名时,用MsgBox显示文件名(不显示路径名)。
注意:程序中不得使用任何变量;保存时必须存放在考生文件夹下,窗体文件名为sjt1. frm,工程文件名为sjt1.vbp。
2.在名称为Form1的窗体上放置一个名为Text1的文本框控件和一个名为Timer1的计时器控件,程序运行后,文本框中显示的是当前的时间,而且每一秒文本框中所显示的时间都会随时间的变化而改变。
注意:程序中不得使用任何变量;保存时必须存放在考生文件夹下,窗体文件名为sjt2. frm,工程文件名为sjt2.vbp,如图1―1所示。
为您推荐的考试题库
你可能感兴趣的试题
1.问答题 参考答案
热门相关试卷
最新相关试卷14秋学期《windows可视化编程》在线作业-答案_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
14秋学期《windows可视化编程》在线作业-答案
上传于||文档简介
&&1秋​学​期​《​w​i​n​d​o​w​s​可​视​化​编​程​》​在​线​作​业​-​答​案
大小:9.51KB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢

我要回帖

更多关于 excel窗体控件 的文章

 

随机推荐