Windows窗体程序的开发实验报告Word格式文档下载.docx

上传人:b****2 文档编号:14825076 上传时间:2022-10-25 格式:DOCX 页数:15 大小:267.38KB
下载 相关 举报
Windows窗体程序的开发实验报告Word格式文档下载.docx_第1页
第1页 / 共15页
Windows窗体程序的开发实验报告Word格式文档下载.docx_第2页
第2页 / 共15页
Windows窗体程序的开发实验报告Word格式文档下载.docx_第3页
第3页 / 共15页
Windows窗体程序的开发实验报告Word格式文档下载.docx_第4页
第4页 / 共15页
Windows窗体程序的开发实验报告Word格式文档下载.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

Windows窗体程序的开发实验报告Word格式文档下载.docx

《Windows窗体程序的开发实验报告Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《Windows窗体程序的开发实验报告Word格式文档下载.docx(15页珍藏版)》请在冰豆网上搜索。

Windows窗体程序的开发实验报告Word格式文档下载.docx

1.学会在VisualStudio2021中创立和运行窗体程序。

2.掌握Windows窗体的根本操作。

3.学会使用常用的Windows控件。

4.学会使用菜单和工具栏以及通用对话框。

二、实验环境

.NET框架开发环境VisualStudio2021

三、实验内容

例5-1、2:

源代码:

publicpartialclassForm1:

Form

{

publicForm1()

Initializeponent();

}

privatevoidAddInputToLog(stringinput)

this.tbLog.AppendText("

\r\n"

+input);

this.tbLog.ScrollToCaret();

privatevoidbtnSubmit_Click(objectsender,EventArgse)

stringinput=this.tbInput.Text;

this.AddInputToLog(input);

this.tbInput.Clear();

}

例5-3、4:

publicpartialclassFrmMain:

publicFrmMain()

privatevoidbtnSetProp_Click(objectsender,EventArgse)

this.Text="

测试对话框"

;

this.FormBorderStyle=FormBorderStyle.FixedDialog;

this.BackColor=Color.Gray;

this.WindowState=FormWindowState.Normal;

this.MinimizeBox=false;

this.Height=200;

this.Width=400;

this.TopMost=true;

privateFrmMain_CurrFrm=null;

privatevoidbtnCreate_Click(objectsender,EventArgse)

if(this._CurrFrm==null)

this._CurrFrm=newFrmMain();

this._CurrFrm.Show();

}

else

this._CurrFrm.Activate();

privatevoidbtnClose_Click(objectsender,EventArgse)

if(this._CurrFrm!

=null)

this._CurrFrm.Close();

this._CurrFrm=null;

privatevoidFrmMain_Load(objectsender,EventArgse)

例5-5:

//label1参数设置

this.label1.AutoSize=true;

this.label1.BackColor=System.Drawing.Color.Red;

this.label1.Font=newSystem.Drawing.Font("

楷体"

12F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,

((byte)(134)));

this.label1.ForeColor=System.Drawing.Color.White;

this.label1.Location=newSystem.Drawing.Point(68,43);

this.label1.Name="

label1"

this.label1.Size=newSystem.Drawing.Size(232,16);

this.label1.TabIndex=0;

this.label1.Text="

红底白字,楷体小四号,无边框"

this.label1.Click+=newSystem.EventHandler(this.label1_Click);

//label2参数设置

this.label2.AutoSize=true;

this.label2.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;

this.label2.Font=newSystem.Drawing.Font("

幼圆"

15F,

System.Drawing.FontStyle.Bold,

System.Drawing.GraphicsUnit.Point,

this.label2.Location=newSystem.Drawing.Point(49,79);

this.label2.Name="

label2"

this.label2.Size=newSystem.Drawing.Size(289,22);

this.label2.TabIndex=1;

this.label2.Text="

幼圆小三粗体,Single边框"

this.label2.Click+=newSystem.EventHandler(this.label2_Click);

例5-6:

privateint_Value=0;

//btnShowMsg的Click事件处理函数

privatevoidbtnShowMsg_Click(objectsender,EventArgse)

MessageBox.Show(string.Format("

现在需要:

{0}"

this._Value));

//“多一点〞按钮Click事件处理函数

privatevoidbtnAdd_Click(objectsender,EventArgse)

this._Value++;

this.lbRes.Text=string.Format("

this._Value);

//“少一点〞按钮Click事件处理函数

privatevoidbtnSub_Click(objectsender,EventArgse)

this._Value--;

例5-7:

privatevoidbuttons_CheckedChanged(objectsender,EventArgse)

stringweeks="

"

weeks+=ckbWeek1.Checked?

"

星期一"

:

weeks+=ckbWeek2.Checked?

星期二"

weeks+=ckbWeek3.Checked?

星期三"

weeks+=ckbWeek4.Checked?

星期四"

weeks+=ckbWeek5.Checked?

星期五"

weeks+=ckbWeek6.Checked?

星期六"

weeks+=ckbWeek7.Checked?

星期日"

stringsport="

sport+=rbSword.Checked?

击剑"

sport+=rbJump.Checked?

跳水"

sport+=rbTiCao.Checked?

体操"

stringjiangpai="

jiangpai+=rbGold.Checked?

金牌"

jiangpai+=rbSliver.Checked?

银牌"

jiangpai+=rbTong.Checked?

铜牌"

this.lbHint.Text=weeks+sport+jiangpai;

例5-8:

privatevoidForm1_Load(objectsender,EventArgse)

this.mtbMobile.Mask="

//手机:

13后面9个必填数字

this.mtbPhone.Mask="

00"

//:

4位必填区号,7或8位?

this.tbName.Text="

this.tbUsers.Text="

stringusr=string.Format("

<

{0}>

:

{1}>

{2}>

//产生用户信息

this.tbName.Text,

this.mtbPhone.Text,

this.mtbMobile.Text);

//添加到用户记录文本框¨

°

this.tbUsers.AppendText(usr+System.Environment.NewLine);

this.mtbMobile.Text="

//清空用户信息

this.mtbPhone.Text="

例5-9:

//设置cmbHouXuan只能从boBox中的已有候选值选择

thisbHouXuan.DropDownStyle=boBoxStyle.DropDownList;

//lstResult只能执行单项选择,并且对所有值进展排序

this.lstResults.SelectionMode=SelectionMode.One;

this.lstResults

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 人力资源管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1