C#实验6Word下载.docx
- 文档编号:19928211
- 上传时间:2023-01-12
- 格式:DOCX
- 页数:21
- 大小:97.26KB
C#实验6Word下载.docx
《C#实验6Word下载.docx》由会员分享,可在线阅读,更多相关《C#实验6Word下载.docx(21页珍藏版)》请在冰豆网上搜索。
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
privatevoidmenuStrip3_ItemClicked(objectsender,ToolStripItemClickedEventArgse)
privatevoidtoolStripMenuItem1_Click(objectsender,EventArgse)
privatevoid退出ToolStripMenuItem_Click(objectsender,EventArgse)
privatevoidMenuStrip_Close_Clock(objectsender,EventArgse)
this.Close();
}
抓图的结果:
使用文件->
打开可以打开一个对话框,如下图:
实验6-2:
练习使用按钮、单选按钮和复选框等窗体控件
1.MyForm.cs
namespace试验6__2
publicpartialclassMyForm:
publicMyForm()
privatevoidcheckBox_lv_CheckedChanged(objectsender,EventArgse)
privatevoidcheckBox_lan_CheckedChanged(objectsender,EventArgse)
privatevoidMyForm_Load(objectsender,EventArgse)
privatevoidradioButton_hong_CheckedChanged(objectsender,EventArgse)
if(this.radioButton_hong.Checked==true)
this.BackColor=Color.Red;
privatevoidbutton1_Click(objectsender,EventArgse)
privatevoidcheckBox_hong_CheckedChanged(objectsender,EventArgse)
if(this.checkBox_hong.Checked==true)
this.textBox1.Text=textBox1.Text+checkBox_hong.Text+"
"
;
privatevoidradioButton_lv_CheckedChanged(objectsender,EventArgse)
if(this.radioButton_lv.Checked==true)
this.BackColor=Color.Green;
privatevoidradioButton_lan_CheckedChanged(objectsender,EventArgse)
if(this.radioButton_lan.Checked==true)
this.BackColor=Color.Blue;
privatevoidcheckBox_lv_CheckedChanged_1(objectsender,EventArgse)
if(this.checkBox_lv.Checked==true)
this.textBox1.Text=textBox1.Text+checkBox_lv.Text+"
privatevoidgroupBox2_Enter(objectsender,EventArgse)
privatevoidcheckBox_lan_CheckedChanged_1(objectsender,EventArgse)
if(this.checkBox_lan.Checked==true)
this.textBox1.Text=textBox1.Text+checkBox_lan.Text+"
privatevoidcheckBox_cheng_CheckedChanged(objectsender,EventArgse)
if(this.checkBox_cheng.Checked==true)
this.textBox1.Text=textBox1.Text+checkBox_cheng.Text+"
privatevoidcheckBox_huang_CheckedChanged(objectsender,EventArgse)
if(this.checkBox_huang.Checked==true)
this.textBox1.Text=textBox1.Text+checkBox_huang.Text+"
privatevoidcheckBox_zi_CheckedChanged(objectsender,EventArgse)
if(this.checkBox_zi.Checked==true)
this.textBox1.Text=textBox1.Text+checkBox_zi.Text+"
privatevoidradioButton_hong_CheckedChanged_1(objectsender,EventArgse)
privatevoidtextBox1_TextChanged(objectsender,EventArgse)
2.MyForm.Designer.cs
partialclassMyForm
///<
summary>
///必需的设计器变量。
/summary>
privateSystem.ComponentModel.IContainercomponents=null;
///清理所有正在使用的资源。
paramname="
disposing"
>
如果应释放托管资源,为true;
否则为false。
<
/param>
protectedoverridevoidDispose(booldisposing)
if(disposing&
&
(components!
=null))
components.Dispose();
base.Dispose(disposing);
#regionWindows窗体设计器生成的代码
///设计器支持所需的方法-不要
///使用代码编辑器修改此方法的内容。
privatevoidInitializeComponent()
this.radioButton_hong=newSystem.Windows.Forms.RadioButton();
this.radioButton_lv=newSystem.Windows.Forms.RadioButton();
this.radioButton_lan=newSystem.Windows.Forms.RadioButton();
this.groupBox1=newSystem.Windows.Forms.GroupBox();
this.groupBox2=newSystem.Windows.Forms.GroupBox();
this.checkBox_zi=newSystem.Windows.Forms.CheckBox();
this.checkBox_huang=newSystem.Windows.Forms.CheckBox();
this.checkBox_cheng=newSystem.Windows.Forms.CheckBox();
this.checkBox_lan=newSystem.Windows.Forms.CheckBox();
this.checkBox_lv=newSystem.Windows.Forms.CheckBox();
this.checkBox_hong=newSystem.Windows.Forms.CheckBox();
this.textBox1=newSystem.Windows.Forms.TextBox();
this.button1=newSystem.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
//radioButton_hong
this.radioButton_hong.AutoSize=true;
this.radioButton_hong.Location=newSystem.Drawing.Point(6,21);
this.radioButton_hong.Name="
radioButton_hong"
this.radioButton_hong.Size=newSystem.Drawing.Size(35,16);
this.radioButton_hong.TabIndex=4;
this.radioButton_hong.TabStop=true;
this.radioButton_hong.Text="
红"
this.radioButton_hong.UseVisualStyleBackColor=true;
this.radioButton_hong.CheckedChanged+=newSystem.EventHandler(this.radioButton_hong_CheckedChanged_1);
//radioButton_lv
this.radioButton_lv.AutoSize=true;
this.radioButton_lv.Location=newSystem.Drawing.Point(6,64);
this.radioButton_lv.Name="
radioButton_lv"
this.radioButton_lv.Size=newSystem.Drawing.Size(35,16);
this.radioButton_lv.TabIndex=5;
this.radioButton_lv.TabStop=true;
this.radioButton_lv.Text="
绿"
this.radioButton_lv.UseVisualStyleBackColor=true;
this.radioButton_lv.CheckedChanged+=newSystem.EventHandler(this.radioButton_lv_CheckedChanged);
//radioButton_lan
this.radioButton_lan.AutoSize=true;
this.radioButton_lan.Location=newSystem.Drawing.Point(6,113);
this.radioButton_lan.Name="
radioButton_lan"
this.radioButton_lan.Size=newSystem.Drawing.Size(35,16);
this.radioButton_lan.TabIndex=6;
this.radioButton_lan.TabStop=true;
this.radioButton_lan.Text="
蓝"
this.radioButton_lan.UseVisualStyleBackColor=true;
this.radioButton_lan.CheckedChanged+=newSystem.EventHandler(this.radioButton_lan_CheckedChanged);
//groupBox1
this.groupBox1.Controls.Add(this.radioButton_hong);
this.groupBox1.Controls.Add(this.radioButton_lan);
this.groupBox1.Controls.Add(this.radioButton_lv);
this.groupBox1.Location=newSystem.Drawing.Point(12,2);
this.groupBox1.Name="
groupBox1"
this.groupBox1.Size=newSystem.Drawing.Size(145,144);
this.groupBox1.TabIndex=3;
this.groupBox1.TabStop=false;
this.groupBox1.Text="
背景颜色"
//groupBox2
this.groupBox2.Controls.Add(this.checkBox_zi);
this.groupBox2.Controls.Add(this.checkBox_huang);
this.groupBox2.Controls.Add(this.checkBox_cheng);
this.groupBox2.Controls.Add(this.checkBox_lan);
this.groupBox2.Controls.Add(this.checkBox_lv);
this.groupBox2.Controls.Add(this.checkBox_hong);
this.groupBox2.Location=newSystem.Drawing.Point(176,2);
this.groupBox2.Name="
groupBox2"
this.groupBox2.Size=newSystem.Drawing.Size(213,144);
this.groupBox2.TabIndex=4;
this.groupBox2.TabStop=false;
this.groupBox2.Text="
你喜欢的颜色"
this.groupBox2.Enter+=newSystem.EventHandler(this.groupBox2_Enter);
//checkBox_zi
this.checkBox_zi.AutoSize=true;
this.checkBox_zi.Location=newSystem.Drawing.Point(106,113);
this.checkBox_zi.Name="
checkBox_zi"
this.checkBox_zi.Size=newSystem.Drawing.Size(36,16);
this.checkBox_zi.TabIndex=6;
this.checkBox_zi.Text="
紫"
this.checkBox_zi.UseVisualStyleBackColor=true;
this.checkBox_zi.CheckedChanged+=newSystem.EventHandler(this.checkBox_zi_CheckedChanged);
//checkBox_huang
this.checkBox_huang.AutoSize=true;
this.checkBox_huang.Location=newSystem.Drawing.Point(106,64);
this.checkBox_huang.Name="
checkBox_huang"
this.checkBox_huang.Size=newSystem.Drawing.Size(36,16);
this.checkBox_huang.TabIndex=5;
this.checkBox_huang.Text="
黄"
this.checkBox_huang.UseVisualStyleBackColor=true;
this.checkBox_huang.CheckedChanged+=newSystem.EventHandler(this.checkBox_huang_CheckedChanged);
//checkBox_cheng
this.checkBox_cheng.AutoSize=true;
this.checkBox_cheng.Location=newSystem.Drawing.Point(106,21);
this.checkBox_cheng.Name="
checkBox_cheng"
this.checkBox_cheng.Size=newSystem.Drawing.Size(36,16);
this.checkBox_cheng.TabIndex=4;
this.checkBox_cheng.Text="
橙"
this.checkBox_cheng.UseVisualStyleBackColor=true;
this.checkBox_cheng.CheckedChanged+=newSystem.EventHandler(this.checkBox_cheng_CheckedChanged);
//checkBox_lan
this.checkBox_lan.AutoSize=true;
this.checkBox_lan.Location=newSystem.Drawing.Point(6,114);
this.checkBox_lan.Name="
checkBox_lan"
this.checkBox_lan.Size=newSystem.Drawing.Size(36,16);
this.checkBox_lan.TabIndex=3;
this.checkBox_lan.Text="
this.checkBox_lan.UseVisualStyleBackColor=true;
this.checkBox_lan.CheckedChanged+=newSystem.EventHandler(this.checkBox_lan_CheckedChanged_1);
//checkBox_lv
this.checkBox_lv.AutoSize=true;
this.checkBox_lv.Location=newSystem.Drawing.Point(6,65);
this.checkBox_lv.Name="
checkBox_lv"
this.checkBox_lv.Size=newSystem.Drawing.Size(36,16);
this.checkBox_lv.TabIndex=2;
this.checkBox_lv.Text="
this.checkBox_lv.UseVisualStyleBackColor=true;
this.checkBox_lv.CheckedChanged+=newSystem.EventHandler(this.checkBox_lv_CheckedChanged_1);
//checkBox_hong
this.checkBox_hong.AutoSize=true;
this.checkBox_hong.Location=newSystem.Drawing.Point(6,20);
this.checkBox_hong.Name="
checkBox_h
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 实验