C#控件设计论文文档格式.docx
《C#控件设计论文文档格式.docx》由会员分享,可在线阅读,更多相关《C#控件设计论文文档格式.docx(12页珍藏版)》请在冰豆网上搜索。
![C#控件设计论文文档格式.docx](https://file1.bdocx.com/fileroot1/2022-10/28/53d336b4-657e-4d18-b4af-a98dc27e3fb8/53d336b4-657e-4d18-b4af-a98dc27e3fb81.gif)
本课程设计的目的是锻炼学生熟练掌握简单的C#窗体和控件的设计。
使之能够应用VisualStudio程序软件熟练进行窗体小项目的编辑。
希望通过本次练习提高学生使用C#语言控件解决实际问题的能力。
二、问题分析
1、需要实现的系统目标
a)通过VisualStudio程序软件,结合所学内容,进行C#程序控件的编写;
b)所有控件最终设计要达成之前预计实现的各项功能;
c)在功能实现的基础上,力求程序控件界面美观得体;
d)通过所学知识,尽量在控件中添加更多功能。
2、需要实现的功能需求
⑴单击button按钮,实现显示指定字幕功能。
⑵实现checkbox多项选择内容的显示
⑶实现checkedlistbox复选框的多选内容,按钮单击显示
⑷实现radiobutton单项选择框的任意选择,并能在textbox中显示所选内容
⑸实现通过textbox表向listbox表中添加内容,并进行无重复添加、删除操作。
⑹进行combobox多项条件选择输入,并将内容在listbox表中输出。
⑺实现progressBar控件的添加,通过内外循环读取进度条执行速度。
⑻实现tabcontrol添加个人信息内容。
⑼通过向textbox中添加相关内容,listview中能够显示相关信息,并且能够在combobox中设置显示的图标和字母形式。
⑽添加picturebox,进行图片的插入。
⑾加入Label控件,实现输入文字编辑。
⑿实现通过添加MainMenu完成编辑菜单栏,并进行相应设计。
三、程序设计
⑴根据所需内容,按要求在WindowsApplication中添加指定控件。
①选择工具箱,按需求选择窗体控件添加,如图,
②控件名称
图2-1添加Label文字输入,textbox文本框,以及button按钮
图2-2Checkbox所实现的多项选择功能
图2-3Checkedlistbox所实现的复选功能
图2-4RadioButton选择输入功能
图2-5ListBox控件,向listbox中添加信息
图2-6ComboBox组合控件实现效果
图2-7MainMenu控件添加菜单栏
图2-8ProgressBar控件实现进度条读取功能
图2-9TabControl控件添加学生信息
图2-10ListView等控件实现数据信息添加删除等操作
⑵为每个控件添加所需的程序
⑶编辑完毕,运行程序,效果如图:
四、程序实现
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsApplication1
{
publicpartialclassForm1:
Form
{
publicForm1()
InitializeComponent();
}
privatevoidtextBox2_TextChanged(objectsender,EventArgse)
//label1.Text=textBoxUser.Text+"
输入的密码为"
+textBoxPwd.Text;
privatevoidbutton1_Click(objectsender,EventArgse)
MessageBox.Show(this,"
你好,亲爱的"
"
提示"
MessageBoxButtons.OK,MessageBoxIcon.Information);
privatevoidcheckBox3_CheckedChanged(objectsender,EventArgse)//选中选项之后字体会变色
CheckBoxcheckbox=(CheckBox)sender;
if(checkbox.Checked)
checkbox.ForeColor=Color.Yellow;
else
checkbox.ForeColor=Color.Black;
privatevoidbutton2_Click(objectsender,EventArgse)
stringstr="
选择结果:
"
;
str+=(this.checkBox1.Checked==true)?
(this.checkBox1.Text+"
、"
):
"
str+=(this.checkBox2.Checked==true)?
(this.checkBox2.Text+"
str+=(this.checkBox3.Checked==true)?
(this.checkBox3.Text+"
if(str[str.Length-1]=='
、'
)
str=str.Substring(0,str.Length-1);
MessageBox.Show(str);
privatevoidbutton3_Click(objectsender,EventArgse)
for(inti=0;
i<
checkedListBox1.CheckedIndices.Count;
i++)
str+=checkedListBox1.CheckedItems[i]+"
privatevoidradioButton3_CheckedChanged(objectsender,EventArgse)
RadioButtoncheck=(RadioButton)sender;
if(check.Checked)
textBox3.Text=check.Text;
privatevoidForm1_Load(objectsender,EventArgse)
6;
//listBox1.Items.Add("
第"
+(i+1).ToString()+"
项"
);
privatevoidbutton4_Click(objectsender,EventArgse)
boolifExist=false;
if(textBox1.Text!
="
listBox1.Items.Count;
if(this.listBox1.Items[i].ToString()==textBox1.Text)
ifExist=true;
break;
if(!
ifExist)
this.listBox1.Items.Add(textBox4.Text);
privatevoidbutton5_Click(objectsender,EventArgse)
if(listBox1.SelectedIndices.Count>
0)
for(inti=listBox1.SelectedIndices.Count-1;
i>
=0;
i--)
intj=listBox1.SelectedIndices[i];
listBox1.Items.Remove(listBox1.Items[j].ToString());
privatevoid新建NewToolStripMenuItem_Click(objectsender,EventArgse)
MessageBox.Show("
你选择的是“新建”"
privatevoid打开OpenToolStripMenuItem_Click(objectsender,EventArgse)
你选择的是“打开”"
privatevoid退出ExitToolStripMenuItem_Click(objectsender,EventArgse)
Application.Exit();
privatevoid红色ToolStripMenuItem_Click(objectsender,EventArgse)
this.BackColor=Color.Red;
privatevoid白色ToolStripMenuItem_Click(objectsender,EventArgse)
this.BackColor=Color.White;
privatevoid绿色ToolStripMenuItem_Click(objectsender,EventArgse)
this.BackColor=Color.Green;
privatevoid蓝色ToolStripMenuItem_Click(objectsender,EventArgse)
this.BackColor=Color.Blue;
privatevoid黑色ToolStripMenuItem_Click(objectsender,EventArgse)
this.BackColor=Color.Black;
privatevoid测试执行文件所在目录ToolStripMenuItem_Click(objectsender,EventArgse)
exe文件所在目录为:
\n\n"
+Application.StartupPath+"
\n"
privatevoidcomboBox1_SelectedIndexChanged(objectsender,EventArgse)
if(comboBox1.SelectedIndex>
-1&
&
comboBox2.SelectedIndex