精华内容
下载资源
问答
  • c#窗体应用程序实例

    2015-02-04 00:53:01
    包含c#窗体应用程序多个实例,简单易懂,非常适合初学者
  • c#窗体应用实例

    2017-10-28 15:42:02
    理解可视化程序设计,初步学习winfom程序开发。实现一个窗口程序,要求使用菜单、工具栏、 Textbox、按钮等不少于5种类型的控件,尽量多尝试不同类型控件的使用。
  • C# Windows窗体应用程序设计 简易实例操作(一)

    千次阅读 多人点赞 2020-04-18 16:52:20
    C# Windows窗体应用程序设计 简易实例操作(一) 大家好,这是我第一次写博客。写这个的目的一来是为了巩固自己所学的东西,二是希望通过简单的例子来激发对编程学习的热情,互相促进学习。在后面我也会更新其他的...

    C# Windows窗体应用程序设计

                    简易实例操作(一)
    

    大家好,这是我第一次写博客。写这个的目的一来是为了巩固自己所学的东西,二是希望通过简单的例子来激发对编程学习的热情,互相促进学习。在后面我也会更新其他的内容,第一次写难免有不足的地方,希望大家指正,有什么问题也可以留言讨论,谢谢大家。

    1. 实例运行环境

    Microsoft Visual Studio 2017,下面附上下载链接。
    单击此处即可
    进入网站后下载社区版(community),CSDN里面也有写好的安装教程。

    实际案例及操作

    1概要

    通过对一般例子的掌握,熟悉各个控件作用及其操作方法,进而加深和流利地进行c# Windows窗体应用程序的开发。因为c# Windows窗体应用程序控件比较多,每次以单独的控件加上简单案例,在熟悉以后可以综合起来解决一些比较大的问题。
    主菜单设计
    ① 首先新建一个名为MainMenu的窗体应用程序,将窗体 Text属性设为“主菜单演示”。命名直接在该部件的Text属性栏,双击后输入。
    ② 在“工具箱”中找到“公共控件”,并在其中选取“TextBox”,并将其拖动其进入窗体,在窗体中添加一个文本框textBox1。每个控件的Text属性是设置窗体能够显现的名字的作用。新安装的vs2017如果没有发现工具箱,则需在“视图”里面打开,或者按Ctrl+alt+X,即可出现。
    ③ 继续在工具箱中找到“菜单和工具栏”,在选中“MenuStrip”,并拖动其进入窗体,即下图一中居中的白框(该框可以横向拉伸);然后建立如图所示菜单(如图二)
    ==图一==
    图二
    在输入菜单选项名称时,可为菜单项添加快捷键方式,格式为(&+任意字符),以本例子中的“文件”为例,在输入名字时,在后面添加(&F),程序运行后,按alt+F即可快速打开该菜单栏。以该方式设置的快捷键都是alt+设置的字符打开。
    ④ 代码:c# Windows窗体应用设计中,添加控件只是完成了一部分,如果不向其中添加代码,则不会有所预想的功能。添加代码的方式为双击相应的控件,即可跳转到相应位置。
    下面附上代码:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    namespace 主菜单设计
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
         private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
            }
            private void 重置RToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.Text = "欢迎使用主菜单";
            }
            private void 清空CToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.Text = "";
            }
            private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)
            {
                this.Close();
            }
            private void 关于AToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("主菜单演示,菜单选项的使用", "提示");
            }
            private void Form1_Load(object sender, EventArgs e)
            {
            }
        }
    }
    
    

    ⑤ 运行效果图:
    运行效果图
    今天的分享到此结束,在最开始给的例子比较简单,后面会慢慢增加难度的,有什么建议或者问题可以留言。

    展开全文
  • C# Windows窗体应用程序设计综合实例(二)--------学生成绩管理系统 今天给大家更新一个综合实例,学生成绩管理系统。从需求分析、窗体应用程序的编写、运行结果来阐述整个过程 需求分析 首先先要进行需求分析,...

    C# Windows窗体应用程序设计综合实例(二)--------学生成绩管理系统

    今天给大家更新一个综合实例,学生成绩管理系统。从需求分析、窗体应用程序的编写、运行结果来阐述整个过程
    (文末和评论区有源代码文件,需要自取,建议先看内容再看源代码,代码描述部分可忽略,比较长,影响观看时间。)

    需求分析

    首先先要进行需求分析,需求分析就是想清楚你写的窗体应用具体要实现哪些功能。最好把它用表格的形式列出来。本次实例的需求如下表格。

    窗体功能描述
    主窗体对整个系统的功能进行汇总和导航
    添加对输入系统内的学生成绩进行添加输入数据
    保存至TXT将系统内的成绩导出系统
    从TXT导入从系统外导入成绩信息
    查找根据特定信息查找学生的成绩信息
    排序按照特定要求进行降序或者升序排序
    删除对特定学生的成绩信息进行删除
    修改找到学生信息再修改相应的值

    接下来我们了解了需求后,就开始在大脑里面构思具体的一个情景。

    整体构思

    假定这个系统完成了,你在使用的时候首先出现的应该是导航的页面,也就是主窗体,上面有各个功能的按钮。然后接着是每个功能对应的窗体的情景。最后退出结束。这一步的目的是为了在写的时候有一个大致的布局和编写习惯的预定判定。就像是一个工程师在心里画好了图纸,到时候就不用考虑布局和习惯的问题,只需要关注代码之间的逻辑和语法问题
    在这里插入图片描述
    下面就是整个最煎熬的步骤了,也就是按照前面说讲的窗体应用程序设计的步骤来完成。

    窗体应用程序设计的编写

    选取学生信息的存储结构

    本次由于是做成绩管理系统,就要想好具体在程序里面的存储结构。这里我们用典型的单链表作为存储结构来存储学生的各项信息。
    那么可能有一部分不太了解数据结构的小伙伴就比较疑惑了,接下来简单介绍一下单链表。
    单链表的结构如下:
    在这里插入图片描述
    每个节点由数据域和指针域构成,在开头的的节点有一个头指针。该存储结构的优点是在进行某些操作的时候便于修改。具体的内容自行查找知识点,这里不做过多解释。(文末和评论区有源代码,需要自取)

    设置布局

    接下来我们就开始设置窗体的布局,如下图所示:
    1.主界面
    在这里插入图片描述
    2.修改在这里插入图片描述
    3.添加在这里插入图片描述
    4.删除在这里插入图片描述
    5.排序
    在这里插入图片描述
    6.查找
    在这里插入图片描述
    在这里说明一下,在写的过程中,最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱。

    控件布局及属性设置

    在了解了布局后,我们接下来根据具体的要求进行属性的设置,属性设置如下:
    注意:控件较多的情况下,name属性会自动命名为控件名+加入的顺序,例如加入两个label,第一个自动命名为label1,第二个就为label2。因此后面添加控件按照表格的顺序来一个一个搞好再添加,不然容易混乱与代码对不上。
    在这里插入图片描述
    在这里再强调一下,最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱!
    最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱!
    最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱! 重要的事情说三遍。
    2.排序在这里插入图片描述
    3.查找
    在这里插入图片描述
    4.删除
    在这里插入图片描述
    5.修改
    在这里插入图片描述
    在这里插入图片描述
    6.添加
    在这里插入图片描述
    在这里插入图片描述
    严格注意区分name属性里面的大小写,具体事项见备注。

    添加代码

    添加代码的方法就是双击你的控件,对应的添加。具体的可以看主页之前写的匹配游戏设计和数学测验器。

    ***************************************
    前方高能,非战斗人员请撤离
    请爱护好自己的眼睛
    ***************************************
    1.Program.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;
        namespace C_sharp学生成绩管理系统
        {
            public class Node
            {
                //数据域,当前结点数据
    
                //信息
                public int id;
                public string name;
                public string classnum;
            internal object tiyu;
            internal object yingyu;
            internal object shuxue;
            //分数
            public int c_sharp { set; get; }
                public int ds { set; get; }
                public int maogai { set; get; }
                public int ps { set; get; }   
                public int sports { set; get; }
    
                public double total { set; get; }
                public double average { set; get; }
                //指针   
                public Node Next { set; get; }    //位置域,下一个结点地址
                //构造函数
                public Node(int id, string name, string classnum, int c_sharp, int ds, int maogai, int ps,int sports)
                {
                    this.id = id;
                    this.name = name;
                    this.classnum = classnum;
                    this.c_sharp = c_sharp;
                    this.ds = ds;
                    this.maogai = maogai;
                    this.ps = ps;
                    this.sports = sports;
    
                    this.total = this.c_sharp + this.ds + this.maogai + this.ps  + this.sports;
                    this.average = this.total / 6;
    
                    this.Next = null;
                }
            }
            public class LinkList
            {
                public Node Head { set; get; } //单链表头
                public int total { set; get; } //总人数
    
                //构造
                public LinkList()
                {
                    Head = null;
                    total = 0;
                }
    
                //增加新元素到单链表末尾
                public static void Append(int id, string name, string classnum, int c_sharp, int ds, int maogai, int ps,  int sports)
                {
                    Node foot = new Node(id, name, classnum, c_sharp, ds,maogai, ps,  sports);
                    Node A = new Node(id, name, classnum, c_sharp, ds, maogai, ps, sports);
    
                    if (PublicValue.Head == null)
                    {
                        PublicValue.Head = foot;
                        return;
                    }
                    A = PublicValue.Head;
                    while (A.Next != null)
                    {
                        A = A.Next;
                    }
                    A.Next = foot;
                }
            }
    
            //全局变量
            public class PublicValue
            {
                public static Node Head; //单链表头
                public static Node Tail; //单链表尾
                public static int total; //学生总数
            }
            /// 应用程序的主入口点
            static class Program
            {
                /// <summary>
                /// 应用程序的主入口点
                /// </summary>
                [STAThread]
                static void Main()
                {
                    LinkList link = new LinkList();
    
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }
            }
        }
    
    

    2.主界面:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;//Stream流类
    
    namespace C_sharp学生成绩管理系统
    {
        public partial class MainForm : Form
        {
    
            public MainForm()
            {
                InitializeComponent();
            }
    
           
    
            private void SaveTXT_Click_1(object sender, EventArgs e)
            {
                //清空txt
                System.IO.File.WriteAllText(@"data.txt", string.Empty);
    
                //写入
                StreamWriter sw = new StreamWriter("data.txt", true, Encoding.Default);
                Node B = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                B = PublicValue.Head;
    
                sw.Write(PublicValue.total + "\r\n");
                while (B != null)
                {
                    sw.Write(B.id + "\r\n" + B.classnum + "\r\n" + B.name + "\r\n" + B.c_sharp + "\r\n" + B.ds + "\r\n" + B.maogai + "\r\n" + B.ps + "\r\n" + +B.sports + "\r\n");
                    B = B.Next;
                }
    
                //清空缓冲区
                sw.Flush();
    
                //关闭流
                sw.Close();
    
                MessageBox.Show("保存成功");
            }
    
            private void AppendTxt_Click(object sender, EventArgs e)
            {
                int i;
    
                FileStream fs = new FileStream("data.txt", FileMode.Open);
                StreamReader sr = new StreamReader(fs, Encoding.Default);
    
                //临时接收
                int id;
                string name;
                string classnum;
                int c_sharp;
                int ds;
                int maogai;
                int ps;
                int sports;
    
                PublicValue.total = int.Parse(sr.ReadLine());
    
                for (i = 0; i < PublicValue.total; i++)
                {
                    id = int.Parse(sr.ReadLine());
                    name = sr.ReadLine();
                    classnum = sr.ReadLine();
    
                    c_sharp = int.Parse(sr.ReadLine());
                    ds = int.Parse(sr.ReadLine());
                    maogai = int.Parse(sr.ReadLine());
                    ps = int.Parse(sr.ReadLine());
                    sports = int.Parse(sr.ReadLine());
    
                    LinkList.Append(id, classnum, name, c_sharp, ds, maogai, ps, sports);
    
                }
                sr.Close();
                MessageBox.Show("导入成功");
                List_Click_1(null, null);
            }
    
            private void List_Click_1(object sender, EventArgs e)
            {
                Node B = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                B = PublicValue.Head;
    
                Change.Text = "";//先清空
                Change.Text += "  学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
                while (B != null)
                {
                    Change.Text += B.id + " \t" + B.classnum + "\t" + B.name + "\t" + B.c_sharp + "\t" + B.ds + "\t" + "\t" + B.maogai + "\t" + B.ps + "\t" +  + B.sports + "\t" + B.total + "\t" + B.average.ToString("f2") + "\r\n";
                    B = B.Next;
                }
            }
    
            private void ch_Click(object sender, EventArgs e)
            {
                ChangeStuForm f3 = new ChangeStuForm();
                f3.ShowDialog();
                List_Click_1(null, null);
            }
    
            private void Delete_Click_1(object sender, EventArgs e)
            {
                DelStuForm f4 = new DelStuForm();
                f4.ShowDialog();
                List_Click_1(null, null);
            }
    
            private void Find_Click_1(object sender, EventArgs e)
            {
    
                FindForm f6 = new FindForm();
                f6.ShowDialog();
            }
    
            private void Sort_Click_1(object sender, EventArgs e)
            {
                SortForm f5 = new SortForm();
                f5.ShowDialog();
                List_Click_1(null, null);
            }
    
            private void Exit_Click_1(object sender, EventArgs e)
            {
                System.Environment.Exit(0);
            }
    
            private void Add_Click(object sender, EventArgs e)
            {
                AddStuForm f2 = new AddStuForm();
                f2.ShowDialog();
                List_Click_1(null, null);
            }
    
            private void MainForm_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    

    3.修改

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace C_sharp学生成绩管理系统
    {
        public partial class ChangeStuForm : Form
        {
            private Button button1;
            private Button button2;
            private TextBox textBox1;
            private TextBox textBox2;
            private TextBox textBox3;
            private TextBox textBox4;
            private TextBox textBox5;
            private TextBox textBox6;
            private TextBox textBox7;
            private TextBox textBox8;
            private Label label1;
            private Label label2;
            private Label label3;
            private Label label4;
            private Label label5;
            private Label label6;
            private Label label7;
            private Label label8;
            private TextBox textBox9;
            private Label label9;
            private Button button3;
    
            public ChangeStuForm()
            {
                InitializeComponent();
            }
            
            private void InitializeComponent()
            {
                this.button1 = new System.Windows.Forms.Button();
                this.button2 = new System.Windows.Forms.Button();
                this.button3 = new System.Windows.Forms.Button();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.textBox2 = new System.Windows.Forms.TextBox();
                this.textBox3 = new System.Windows.Forms.TextBox();
                this.textBox4 = new System.Windows.Forms.TextBox();
                this.textBox5 = new System.Windows.Forms.TextBox();
                this.textBox6 = new System.Windows.Forms.TextBox();
                this.textBox7 = new System.Windows.Forms.TextBox();
                this.textBox8 = new System.Windows.Forms.TextBox();
                this.label1 = new System.Windows.Forms.Label();
                this.label2 = new System.Windows.Forms.Label();
                this.label3 = new System.Windows.Forms.Label();
                this.label4 = new System.Windows.Forms.Label();
                this.label5 = new System.Windows.Forms.Label();
                this.label6 = new System.Windows.Forms.Label();
                this.label7 = new System.Windows.Forms.Label();
                this.label8 = new System.Windows.Forms.Label();
                this.textBox9 = new System.Windows.Forms.TextBox();
                this.label9 = new System.Windows.Forms.Label();
                this.SuspendLayout();
                // 
                // button1
                // 
                this.button1.BackColor = System.Drawing.SystemColors.Info;
                this.button1.Location = new System.Drawing.Point(75, 372);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(128, 41);
                this.button1.TabIndex = 0;
                this.button1.Text = "确定";
                this.button1.UseVisualStyleBackColor = false;
                this.button1.Click += new System.EventHandler(this.button1_Click_1);
                // 
                // button2
                // 
                this.button2.BackColor = System.Drawing.SystemColors.Info;
                this.button2.Location = new System.Drawing.Point(264, 371);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(140, 41);
                this.button2.TabIndex = 1;
                this.button2.Text = "修改";
                this.button2.UseVisualStyleBackColor = false;
                this.button2.Click += new System.EventHandler(this.button2_Click_1);
                // 
                // button3
                // 
                this.button3.BackColor = System.Drawing.SystemColors.Info;
                this.button3.Location = new System.Drawing.Point(479, 372);
                this.button3.Name = "button3";
                this.button3.Size = new System.Drawing.Size(136, 40);
                this.button3.TabIndex = 2;
                this.button3.Text = "退出";
                this.button3.UseVisualStyleBackColor = false;
                this.button3.Click += new System.EventHandler(this.button3_Click_1);
                // 
                // textBox1
                // 
                this.textBox1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox1.Location = new System.Drawing.Point(94, 46);
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(155, 25);
                this.textBox1.TabIndex = 3;
                // 
                // textBox2
                // 
                this.textBox2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox2.Location = new System.Drawing.Point(94, 96);
                this.textBox2.Name = "textBox2";
                this.textBox2.Size = new System.Drawing.Size(155, 25);
                this.textBox2.TabIndex = 4;
                // 
                // textBox3
                // 
                this.textBox3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox3.Location = new System.Drawing.Point(436, 46);
                this.textBox3.Name = "textBox3";
                this.textBox3.Size = new System.Drawing.Size(130, 25);
                this.textBox3.TabIndex = 5;
                // 
                // textBox4
                // 
                this.textBox4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox4.Location = new System.Drawing.Point(94, 209);
                this.textBox4.Name = "textBox4";
                this.textBox4.Size = new System.Drawing.Size(100, 25);
                this.textBox4.TabIndex = 6;
                // 
                // textBox5
                // 
                this.textBox5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox5.Location = new System.Drawing.Point(304, 209);
                this.textBox5.Name = "textBox5";
                this.textBox5.Size = new System.Drawing.Size(100, 25);
                this.textBox5.TabIndex = 7;
                // 
                // textBox6
                // 
                this.textBox6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox6.Location = new System.Drawing.Point(500, 276);
                this.textBox6.Name = "textBox6";
                this.textBox6.Size = new System.Drawing.Size(100, 25);
                this.textBox6.TabIndex = 8;
                // 
                // textBox7
                // 
                this.textBox7.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox7.Location = new System.Drawing.Point(500, 209);
                this.textBox7.Name = "textBox7";
                this.textBox7.Size = new System.Drawing.Size(100, 25);
                this.textBox7.TabIndex = 9;
                // 
                // textBox8
                // 
                this.textBox8.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox8.Location = new System.Drawing.Point(94, 276);
                this.textBox8.Name = "textBox8";
                this.textBox8.Size = new System.Drawing.Size(100, 25);
                this.textBox8.TabIndex = 10;
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(51, 99);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(37, 15);
                this.label1.TabIndex = 11;
                this.label1.Text = "班级";
                // 
                // label2
                // 
                this.label2.AutoSize = true;
                this.label2.ForeColor = System.Drawing.Color.Blue;
                this.label2.Location = new System.Drawing.Point(393, 49);
                this.label2.Name = "label2";
                this.label2.Size = new System.Drawing.Size(37, 15);
                this.label2.TabIndex = 12;
                this.label2.Text = "姓名";
                // 
                // label3
                // 
                this.label3.AutoSize = true;
                this.label3.Location = new System.Drawing.Point(51, 219);
                this.label3.Name = "label3";
                this.label3.Size = new System.Drawing.Size(37, 15);
                this.label3.TabIndex = 13;
                this.label3.Text = "语文";
                this.label3.Click += new System.EventHandler(this.label3_Click);
                // 
                // label4
                // 
                this.label4.AutoSize = true;
                this.label4.Location = new System.Drawing.Point(261, 212);
                this.label4.Name = "label4";
                this.label4.Size = new System.Drawing.Size(37, 15);
                this.label4.TabIndex = 14;
                this.label4.Text = "数学";
                this.label4.Click += new System.EventHandler(this.label4_Click);
                // 
                // label5
                // 
                this.label5.AutoSize = true;
                this.label5.Location = new System.Drawing.Point(457, 278);
                this.label5.Name = "label5";
                this.label5.Size = new System.Drawing.Size(37, 15);
                this.label5.TabIndex = 15;
                this.label5.Text = "体育";
                this.label5.Click += new System.EventHandler(this.label5_Click);
                // 
                // label6
                // 
                this.label6.AutoSize = true;
                this.label6.Location = new System.Drawing.Point(457, 212);
                this.label6.Name = "label6";
                this.label6.Size = new System.Drawing.Size(37, 15);
                this.label6.TabIndex = 16;
                this.label6.Text = "英语";
                this.label6.Click += new System.EventHandler(this.label6_Click);
                // 
                // label7
                // 
                this.label7.AutoSize = true;
                this.label7.Location = new System.Drawing.Point(51, 278);
                this.label7.Name = "label7";
                this.label7.Size = new System.Drawing.Size(37, 15);
                this.label7.TabIndex = 17;
                this.label7.Text = "物理";
                this.label7.Click += new System.EventHandler(this.label7_Click);
                // 
                // label8
                // 
                this.label8.AutoSize = true;
                this.label8.Location = new System.Drawing.Point(51, 46);
                this.label8.Name = "label8";
                this.label8.Size = new System.Drawing.Size(37, 15);
                this.label8.TabIndex = 18;
                this.label8.Text = "学号";
                // 
                // textBox9
                // 
                this.textBox9.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox9.Location = new System.Drawing.Point(304, 278);
                this.textBox9.Name = "textBox9";
                this.textBox9.Size = new System.Drawing.Size(100, 25);
                this.textBox9.TabIndex = 19;
                // 
                // label9
                // 
                this.label9.AutoSize = true;
                this.label9.Location = new System.Drawing.Point(261, 279);
                this.label9.Name = "label9";
                this.label9.Size = new System.Drawing.Size(37, 15);
                this.label9.TabIndex = 20;
                this.label9.Text = "政治";
                // 
                // ChangeStuForm
                // 
                this.BackColor = System.Drawing.SystemColors.InactiveCaption;
                this.ClientSize = new System.Drawing.Size(719, 478);
                this.Controls.Add(this.label9);
                this.Controls.Add(this.textBox9);
                this.Controls.Add(this.label8);
                this.Controls.Add(this.label7);
                this.Controls.Add(this.label6);
                this.Controls.Add(this.label5);
                this.Controls.Add(this.label4);
                this.Controls.Add(this.label3);
                this.Controls.Add(this.label2);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.textBox8);
                this.Controls.Add(this.textBox7);
                this.Controls.Add(this.textBox6);
                this.Controls.Add(this.textBox5);
                this.Controls.Add(this.textBox4);
                this.Controls.Add(this.textBox3);
                this.Controls.Add(this.textBox2);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.button3);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.ForeColor = System.Drawing.Color.Blue;
                this.Name = "ChangeStuForm";
                this.Text = "修改";
                this.Load += new System.EventHandler(this.ChangeStuForm_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                //遍历查找
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                cur = PublicValue.Head;//从头开始查找
                int findId = int.Parse(textBox1.Text);
                while (cur != null)
                {
                    if (cur.id == findId)
                    {
                        textBox2.Text = cur.classnum;
                        textBox3.Text = cur.name;
                        textBox4.Text = Convert.ToString(cur.c_sharp);
                        textBox5.Text = Convert.ToString(cur.ds);
                        textBox6.Text = Convert.ToString(cur.maogai);
                        textBox7.Text = Convert.ToString(cur.ps);
                        textBox8.Text = Convert.ToString(cur.sports);
                        break;
                    }
                    cur = cur.Next;
                }
                if (cur == null)
                {
                    MessageBox.Show("你输入的学号不存在!");
                }
            }
    
            private void button2_Click_1(object sender, EventArgs e)
            {
                //再次遍历查找
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                cur = PublicValue.Head;//从头开始查找
                int findId = int.Parse(textBox1.Text);
                while (cur != null)
                {
                    if (cur.id == findId)
                    {
                        cur.classnum = textBox2.Text;
                        cur.name = textBox3.Text;
                        cur.c_sharp = int.Parse(textBox4.Text);
                        cur.ds = int.Parse(textBox5.Text);
                        cur.maogai = int.Parse(textBox6.Text);
                        cur.ps = int.Parse(textBox7.Text);
                        cur.sports = int.Parse(textBox8.Text);
                        cur.total = cur.c_sharp + cur.ds + cur.maogai + cur.ps + cur.sports;
                        cur.average = cur.total / 5;
    
                        MessageBox.Show("修改成功");
                        break;
                    }
                    cur = cur.Next;
                }
                if (cur == null)
                {
                    MessageBox.Show("修改失败,你输入的学号不存在!请不要改变刚才输入的学号");
                }
            }
    
            private void button3_Click_1(object sender, EventArgs e)
            {
                this.Close();
            }
    
            private void label7_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label4_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label6_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label3_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label5_Click(object sender, EventArgs e)
            {
    
            }
    
            private void ChangeStuForm_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    

    *******************************
    看到这里休息一下吧
    ***************
    4.添加

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace C_sharp学生成绩管理系统
    {
        public partial class AddStuForm : Form
        {
            private Button button1;
            private Button button2;
            private Button button3;
            private TextBox textBox1;
            private TextBox textBox2;
            private TextBox textBox3;
            private TextBox textBox4;
            private TextBox textBox5;
            private TextBox textBox6;
            private TextBox textBox7;
            private TextBox textBox8;
            private Label label1;
            private Label label2;
            private Label label3;
            private Label label4;
            private Label label5;
            private Label label6;
            private Label label7;
            private TextBox textBox9;
            private Label label9;
            private Label label8;
    
            public AddStuForm()
            {
                InitializeComponent();
            }
    
            private void InitializeComponent()
            {
                this.button1 = new System.Windows.Forms.Button();
                this.button2 = new System.Windows.Forms.Button();
                this.button3 = new System.Windows.Forms.Button();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.textBox2 = new System.Windows.Forms.TextBox();
                this.textBox3 = new System.Windows.Forms.TextBox();
                this.textBox4 = new System.Windows.Forms.TextBox();
                this.textBox5 = new System.Windows.Forms.TextBox();
                this.textBox6 = new System.Windows.Forms.TextBox();
                this.textBox7 = new System.Windows.Forms.TextBox();
                this.textBox8 = new System.Windows.Forms.TextBox();
                this.label1 = new System.Windows.Forms.Label();
                this.label2 = new System.Windows.Forms.Label();
                this.label3 = new System.Windows.Forms.Label();
                this.label4 = new System.Windows.Forms.Label();
                this.label5 = new System.Windows.Forms.Label();
                this.label6 = new System.Windows.Forms.Label();
                this.label7 = new System.Windows.Forms.Label();
                this.label8 = new System.Windows.Forms.Label();
                this.textBox9 = new System.Windows.Forms.TextBox();
                this.label9 = new System.Windows.Forms.Label();
                this.SuspendLayout();
                // 
                // button1
                // 
                this.button1.BackColor = System.Drawing.SystemColors.Info;
                this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                this.button1.Location = new System.Drawing.Point(34, 369);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(131, 43);
                this.button1.TabIndex = 0;
                this.button1.Text = "添加";
                this.button1.UseVisualStyleBackColor = false;
                this.button1.Click += new System.EventHandler(this.button1_Click_1);
                // 
                // button2
                // 
                this.button2.BackColor = System.Drawing.SystemColors.Info;
                this.button2.Location = new System.Drawing.Point(235, 369);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(122, 43);
                this.button2.TabIndex = 1;
                this.button2.Text = "自动添加";
                this.button2.UseVisualStyleBackColor = false;
                this.button2.Click += new System.EventHandler(this.button2_Click_1);
                // 
                // button3
                // 
                this.button3.BackColor = System.Drawing.SystemColors.Info;
                this.button3.Location = new System.Drawing.Point(445, 369);
                this.button3.Name = "button3";
                this.button3.Size = new System.Drawing.Size(136, 43);
                this.button3.TabIndex = 2;
                this.button3.Text = "退出";
                this.button3.UseVisualStyleBackColor = false;
                this.button3.Click += new System.EventHandler(this.button3_Click_1);
                // 
                // textBox1
                // 
                this.textBox1.BackColor = System.Drawing.SystemColors.ControlLightLight;
                this.textBox1.Location = new System.Drawing.Point(101, 63);
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(166, 25);
                this.textBox1.TabIndex = 3;
                // 
                // textBox2
                // 
                this.textBox2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox2.Location = new System.Drawing.Point(376, 66);
                this.textBox2.Name = "textBox2";
                this.textBox2.Size = new System.Drawing.Size(144, 25);
                this.textBox2.TabIndex = 4;
                this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
                // 
                // textBox3
                // 
                this.textBox3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox3.Location = new System.Drawing.Point(101, 119);
                this.textBox3.Name = "textBox3";
                this.textBox3.Size = new System.Drawing.Size(166, 25);
                this.textBox3.TabIndex = 5;
                // 
                // textBox4
                // 
                this.textBox4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox4.Location = new System.Drawing.Point(70, 217);
                this.textBox4.Name = "textBox4";
                this.textBox4.Size = new System.Drawing.Size(100, 25);
                this.textBox4.TabIndex = 6;
                // 
                // textBox5
                // 
                this.textBox5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox5.Location = new System.Drawing.Point(282, 279);
                this.textBox5.Name = "textBox5";
                this.textBox5.Size = new System.Drawing.Size(100, 25);
                this.textBox5.TabIndex = 7;
                // 
                // textBox6
                // 
                this.textBox6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox6.Location = new System.Drawing.Point(282, 217);
                this.textBox6.Name = "textBox6";
                this.textBox6.Size = new System.Drawing.Size(100, 25);
                this.textBox6.TabIndex = 8;
                // 
                // textBox7
                // 
                this.textBox7.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox7.Location = new System.Drawing.Point(497, 217);
                this.textBox7.Name = "textBox7";
                this.textBox7.Size = new System.Drawing.Size(100, 25);
                this.textBox7.TabIndex = 9;
                // 
                // textBox8
                // 
                this.textBox8.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox8.Location = new System.Drawing.Point(74, 279);
                this.textBox8.Name = "textBox8";
                this.textBox8.Size = new System.Drawing.Size(100, 25);
                this.textBox8.TabIndex = 10;
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(49, 63);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(37, 15);
                this.label1.TabIndex = 11;
                this.label1.Text = "学号";
                // 
                // label2
                // 
                this.label2.AutoSize = true;
                this.label2.Location = new System.Drawing.Point(313, 69);
                this.label2.Name = "label2";
                this.label2.Size = new System.Drawing.Size(37, 15);
                this.label2.TabIndex = 12;
                this.label2.Text = "姓名";
                // 
                // label3
                // 
                this.label3.AutoSize = true;
                this.label3.Location = new System.Drawing.Point(49, 129);
                this.label3.Name = "label3";
                this.label3.Size = new System.Drawing.Size(37, 15);
                this.label3.TabIndex = 13;
                this.label3.Text = "班级";
                // 
                // label4
                // 
                this.label4.AutoSize = true;
                this.label4.Location = new System.Drawing.Point(31, 220);
                this.label4.Name = "label4";
                this.label4.Size = new System.Drawing.Size(37, 15);
                this.label4.TabIndex = 14;
                this.label4.Text = "语文";
                this.label4.Click += new System.EventHandler(this.label4_Click);
                // 
                // label5
                // 
                this.label5.AutoSize = true;
                this.label5.Location = new System.Drawing.Point(442, 289);
                this.label5.Name = "label5";
                this.label5.Size = new System.Drawing.Size(37, 15);
                this.label5.TabIndex = 15;
                this.label5.Text = "体育";
                this.label5.Click += new System.EventHandler(this.label5_Click);
                // 
                // label6
                // 
                this.label6.AutoSize = true;
                this.label6.Location = new System.Drawing.Point(232, 217);
                this.label6.Name = "label6";
                this.label6.Size = new System.Drawing.Size(37, 15);
                this.label6.TabIndex = 16;
                this.label6.Text = "数学";
                this.label6.Click += new System.EventHandler(this.label6_Click);
                // 
                // label7
                // 
                this.label7.AutoSize = true;
                this.label7.Location = new System.Drawing.Point(442, 220);
                this.label7.Name = "label7";
                this.label7.Size = new System.Drawing.Size(37, 15);
                this.label7.TabIndex = 17;
                this.label7.Text = "英语";
                this.label7.Click += new System.EventHandler(this.label7_Click);
                // 
                // label8
                // 
                this.label8.AutoSize = true;
                this.label8.Location = new System.Drawing.Point(31, 289);
                this.label8.Name = "label8";
                this.label8.Size = new System.Drawing.Size(37, 15);
                this.label8.TabIndex = 18;
                this.label8.Text = "物理";
                this.label8.Click += new System.EventHandler(this.label8_Click);
                // 
                // textBox9
                // 
                this.textBox9.BackColor = System.Drawing.SystemColors.ButtonHighlight;
                this.textBox9.Location = new System.Drawing.Point(497, 286);
                this.textBox9.Name = "textBox9";
                this.textBox9.Size = new System.Drawing.Size(100, 25);
                this.textBox9.TabIndex = 19;
                // 
                // label9
                // 
                this.label9.AutoSize = true;
                this.label9.Location = new System.Drawing.Point(232, 279);
                this.label9.Name = "label9";
                this.label9.Size = new System.Drawing.Size(37, 15);
                this.label9.TabIndex = 20;
                this.label9.Text = "政治";
                // 
                // AddStuForm
                // 
                this.BackColor = System.Drawing.SystemColors.InactiveCaption;
                this.ClientSize = new System.Drawing.Size(655, 484);
                this.Controls.Add(this.label9);
                this.Controls.Add(this.textBox9);
                this.Controls.Add(this.label8);
                this.Controls.Add(this.label7);
                this.Controls.Add(this.label6);
                this.Controls.Add(this.label5);
                this.Controls.Add(this.label4);
                this.Controls.Add(this.label3);
                this.Controls.Add(this.label2);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.textBox8);
                this.Controls.Add(this.textBox7);
                this.Controls.Add(this.textBox6);
                this.Controls.Add(this.textBox5);
                this.Controls.Add(this.textBox4);
                this.Controls.Add(this.textBox3);
                this.Controls.Add(this.textBox2);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.button3);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.ForeColor = System.Drawing.Color.Blue;
                this.Name = "AddStuForm";
                this.Text = "添加";
                this.Load += new System.EventHandler(this.AddStuForm_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                //临时接收
                int id;
                string name;
                string classnum;
    
                //分数
                int c_sharp;
                int ds;
                int maogai;
                int ps;
                int sports;
    
                id = int.Parse(textBox1.Text);
                name = textBox2.Text;
                classnum = textBox3.Text;
                c_sharp = int.Parse(textBox4.Text);
                ds = int.Parse(textBox5.Text);
                maogai = int.Parse(textBox6.Text);
                ps = int.Parse(textBox7.Text);
                sports = int.Parse(textBox8.Text);
    
                LinkList.Append(id, name, classnum, c_sharp, ds, maogai, ps, sports);
                PublicValue.total++;
                MessageBox.Show("添加成功");
            }
    
            private void button2_Click_1(object sender, EventArgs e)
            {
                Random rd = new Random();
    
                if (Convert.ToString(textBox1.Text) == "")
                {
                    textBox1.Text = Convert.ToString(1);
                }
                else
                {
                    textBox1.Text = Convert.ToString(1 + int.Parse(textBox1.Text));//学号自动顺延
                }
    
                textBox2.Text = "张三";
                textBox3.Text = "计算机科学与技术1班";
    
                textBox4.Text = Convert.ToString(rd.Next(50, 100));
                textBox5.Text = Convert.ToString(rd.Next(50, 100));
                textBox6.Text = Convert.ToString(rd.Next(50, 100));
                textBox7.Text = Convert.ToString(rd.Next(50, 100));
                textBox8.Text = Convert.ToString(rd.Next(50, 100));
            }
    
            private void button3_Click_1(object sender, EventArgs e)
            {
                this.Close();
            }
    
            private void textBox2_TextChanged(object sender, EventArgs e)
            {
    
            }
    
            private void label4_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label6_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label7_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label5_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label8_Click(object sender, EventArgs e)
            {
    
            }
    
            private void AddStuForm_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    

    5.删除

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace C_sharp学生成绩管理系统
    {
        public partial class DelStuForm : Form
        {
            private Button button1;
            private Button button2;
            private Label label1;
            private Label label2;
            private TextBox textBox1;
            private TextBox textBox2;
            private Button button3;
    
            public DelStuForm()
            {
                InitializeComponent();
            }
    
            private void InitializeComponent()
            {
                this.button1 = new System.Windows.Forms.Button();
                this.button2 = new System.Windows.Forms.Button();
                this.button3 = new System.Windows.Forms.Button();
                this.label1 = new System.Windows.Forms.Label();
                this.label2 = new System.Windows.Forms.Label();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.textBox2 = new System.Windows.Forms.TextBox();
                this.SuspendLayout();
                // 
                // button1
                // 
                this.button1.BackColor = System.Drawing.SystemColors.Info;
                this.button1.Location = new System.Drawing.Point(393, 58);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(103, 39);
                this.button1.TabIndex = 0;
                this.button1.Text = "查找";
                this.button1.UseVisualStyleBackColor = false;
                this.button1.Click += new System.EventHandler(this.button1_Click_1);
                // 
                // button2
                // 
                this.button2.BackColor = System.Drawing.SystemColors.Info;
                this.button2.Location = new System.Drawing.Point(410, 425);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(121, 46);
                this.button2.TabIndex = 1;
                this.button2.Text = "删除";
                this.button2.UseVisualStyleBackColor = false;
                this.button2.Click += new System.EventHandler(this.button2_Click_1);
                // 
                // button3
                // 
                this.button3.BackColor = System.Drawing.SystemColors.Info;
                this.button3.Location = new System.Drawing.Point(594, 425);
                this.button3.Name = "button3";
                this.button3.Size = new System.Drawing.Size(93, 46);
                this.button3.TabIndex = 2;
                this.button3.Text = "退出";
                this.button3.UseVisualStyleBackColor = false;
                this.button3.Click += new System.EventHandler(this.button3_Click_1);
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(44, 58);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(37, 15);
                this.label1.TabIndex = 3;
                this.label1.Text = "学号";
                // 
                // label2
                // 
                this.label2.AutoSize = true;
                this.label2.Location = new System.Drawing.Point(44, 127);
                this.label2.Name = "label2";
                this.label2.Size = new System.Drawing.Size(37, 15);
                this.label2.TabIndex = 4;
                this.label2.Text = "信息";
                // 
                // textBox1
                // 
                this.textBox1.BackColor = System.Drawing.Color.Snow;
                this.textBox1.Location = new System.Drawing.Point(96, 58);
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(206, 25);
                this.textBox1.TabIndex = 5;
                // 
                // textBox2
                // 
                this.textBox2.BackColor = System.Drawing.Color.SeaShell;
                this.textBox2.Location = new System.Drawing.Point(96, 124);
                this.textBox2.Multiline = true;
                this.textBox2.Name = "textBox2";
                this.textBox2.Size = new System.Drawing.Size(591, 281);
                this.textBox2.TabIndex = 6;
                // 
                // DelStuForm
                // 
                this.BackColor = System.Drawing.SystemColors.InactiveCaption;
                this.ClientSize = new System.Drawing.Size(783, 483);
                this.Controls.Add(this.textBox2);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.label2);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.button3);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.ForeColor = System.Drawing.Color.Blue;
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
                this.Name = "DelStuForm";
                this.Text = "删除";
                this.Load += new System.EventHandler(this.DelStuForm_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                cur = PublicValue.Head;
    
                textBox2.Text = "";//先清空
                textBox2.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\r\n";
    
                int findId = int.Parse(textBox1.Text);
                while (cur != null)
                {
                    if (cur.id == findId)
                    {
                        textBox2.Text += cur.id + "\t";
                        textBox2.Text += cur.classnum + "\t";
                        textBox2.Text += cur.name + "\t";
                        textBox2.Text += cur.c_sharp + "\t";
                        textBox2.Text += cur.ds + "\t"+"\t";
                        textBox2.Text += cur.maogai + "\t";
                        textBox2.Text += cur.ps + "\t";
                        textBox2.Text += cur.sports;
                        break;
                    }
                    cur = cur.Next;
                }
                if (cur == null)
                {
                    MessageBox.Show("你输入的学号不存在!");
                }
            }
    
            private void button2_Click_1(object sender, EventArgs e)
            {
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//大哥
                Node last = new Node(0, "0", "0", 0, 0, 0, 0, 0);//小弟
    
                cur = PublicValue.Head;
                last = cur;
    
                int findId = int.Parse(textBox1.Text);
    
                //查找
                while (cur != null)
                {
                    if (cur.id == findId)//如果找到了
                    {
                        PublicValue.total--;
    
                        if (cur == PublicValue.Head)//如果删除的是头节点
                        {
                            PublicValue.Head = PublicValue.Head.Next;
                            MessageBox.Show("删除成功");
                            return;
                        }
                        else
                        {
                            last.Next = cur.Next;//垃圾回收机制,不需要自己清理内存
                            MessageBox.Show("删除成功");
                            return;
                        }
                    }
                    last = cur;//小弟踩大哥脚印
                    cur = cur.Next;//大哥先走一步
                }
    
                if (cur == null)
                {
                    MessageBox.Show("你删除的学号不存在!");
                }
    
            }
    
            private void button3_Click_1(object sender, EventArgs e)
            {
                this.Close();
            }
    
            private void DelStuForm_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    

    6.排序

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace C_sharp学生成绩管理系统
    {
        public partial class SortForm : Form
        {
            private Button button1;
            private Button button2;
            private Button button3;
            private Button button4;
            private Button button5;
            private TextBox textBox1;
            private Label label1;
            private ComboBox comboBox1;
    
            public SortForm()
            {
                InitializeComponent();
            }
    
    
            private void InitializeComponent()
            {
                this.button1 = new System.Windows.Forms.Button();
                this.button2 = new System.Windows.Forms.Button();
                this.button3 = new System.Windows.Forms.Button();
                this.button4 = new System.Windows.Forms.Button();
                this.button5 = new System.Windows.Forms.Button();
                this.comboBox1 = new System.Windows.Forms.ComboBox();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.label1 = new System.Windows.Forms.Label();
                this.SuspendLayout();
                // 
                // button1
                // 
                this.button1.BackColor = System.Drawing.SystemColors.Info;
                this.button1.Location = new System.Drawing.Point(614, 12);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(112, 44);
                this.button1.TabIndex = 0;
                this.button1.Text = "按课程排序";
                this.button1.UseVisualStyleBackColor = false;
                this.button1.Click += new System.EventHandler(this.button1_Click_1);
                // 
                // button2
                // 
                this.button2.BackColor = System.Drawing.SystemColors.Info;
                this.button2.Location = new System.Drawing.Point(39, 12);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(108, 44);
                this.button2.TabIndex = 1;
                this.button2.Text = "按班级排序";
                this.button2.UseVisualStyleBackColor = false;
                this.button2.Click += new System.EventHandler(this.button2_Click_1);
                // 
                // button3
                // 
                this.button3.BackColor = System.Drawing.SystemColors.Info;
                this.button3.Location = new System.Drawing.Point(424, 12);
                this.button3.Name = "button3";
                this.button3.Size = new System.Drawing.Size(93, 44);
                this.button3.TabIndex = 2;
                this.button3.Text = "按总分排序";
                this.button3.UseVisualStyleBackColor = false;
                this.button3.Click += new System.EventHandler(this.button3_Click_1);
                // 
                // button4
                // 
                this.button4.BackColor = System.Drawing.SystemColors.Info;
                this.button4.Location = new System.Drawing.Point(662, 358);
                this.button4.Name = "button4";
                this.button4.Size = new System.Drawing.Size(119, 44);
                this.button4.TabIndex = 3;
                this.button4.Text = "退出";
                this.button4.UseVisualStyleBackColor = false;
                this.button4.Click += new System.EventHandler(this.button4_Click_1);
                // 
                // button5
                // 
                this.button5.BackColor = System.Drawing.SystemColors.Info;
                this.button5.Location = new System.Drawing.Point(221, 12);
                this.button5.Name = "button5";
                this.button5.Size = new System.Drawing.Size(95, 44);
                this.button5.TabIndex = 4;
                this.button5.Text = "按学号排序";
                this.button5.UseVisualStyleBackColor = false;
                this.button5.Click += new System.EventHandler(this.button5_Click_1);
                // 
                // comboBox1
                // 
                this.comboBox1.BackColor = System.Drawing.Color.WhiteSmoke;
                this.comboBox1.ForeColor = System.Drawing.Color.MediumPurple;
                this.comboBox1.FormattingEnabled = true;
                this.comboBox1.Items.AddRange(new object[] {
                "语文",
                "数学",
                "英语",
                "物理",
                "政治",
                "体育"});
                this.comboBox1.Location = new System.Drawing.Point(614, 62);
                this.comboBox1.Name = "comboBox1";
                this.comboBox1.Size = new System.Drawing.Size(121, 20);
                this.comboBox1.TabIndex = 5;
                // 
                // textBox1
                // 
                this.textBox1.BackColor = System.Drawing.Color.White;
                this.textBox1.Location = new System.Drawing.Point(87, 117);
                this.textBox1.Multiline = true;
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(519, 224);
                this.textBox1.TabIndex = 6;
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(36, 117);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(29, 12);
                this.label1.TabIndex = 7;
                this.label1.Text = "信息";
                // 
                // SortForm
                // 
                this.BackColor = System.Drawing.SystemColors.InactiveCaption;
                this.ClientSize = new System.Drawing.Size(848, 533);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.comboBox1);
                this.Controls.Add(this.button5);
                this.Controls.Add(this.button4);
                this.Controls.Add(this.button3);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.ForeColor = System.Drawing.Color.Blue;
                this.Name = "SortForm";
                this.Text = "排序";
                this.Load += new System.EventHandler(this.SortForm_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);
    
                left = PublicValue.Head;
                right = PublicValue.Head;
    
                if (left == null)
                {
                    MessageBox.Show("无法排序,请先存入数据");
                }
                else
                {
                    for (; left != null; left = left.Next)//最大的数放在左边
                    {
                        right = left;
                        for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                        {
                            if (right.id < rightmin.id)
                            {
                                rightmin = right;
                            }
                        }
    
                        temp.id = rightmin.id;
                        temp.name = rightmin.name;
                        temp.classnum = rightmin.classnum;
                        temp.c_sharp = rightmin.c_sharp;
                        temp.ds = rightmin.ds;
                        temp.maogai = rightmin.maogai;
                        temp.ps = rightmin.ps;
                        temp.sports = rightmin.sports;
                        temp.total = rightmin.total;//补充
                        temp.average = rightmin.average;//补充
    
                        rightmin.id = left.id;
                        rightmin.name = left.name;
                        rightmin.classnum = left.classnum;
                        rightmin.c_sharp = left.c_sharp;
                        rightmin.ds = left.ds;
                        rightmin.maogai = left.maogai;
                        rightmin.ps = left.ps;
                        rightmin.sports = left.sports;
                        rightmin.total = left.total;//补充
                        rightmin.average = left.average;//补充
    
    
                        left.id = temp.id;
                        left.name = temp.name;
                        left.classnum = temp.classnum;
                        left.c_sharp = temp.c_sharp;
                        left.ds = temp.ds;
                        left.maogai = temp.maogai;
                        left.ps = temp.ps;
                        left.sports = temp.sports;
                        left.total = temp.total;//补充
                        left.average = temp.average;//补充
                    }
    
                    //输出
                    MessageBox.Show("排序成功");
                    Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
    
                    textBox1.Text = "";//先清空
                    textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
    
                    cur = PublicValue.Head;
    
                    while (cur != null)
                    {
                        textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                        cur = cur.Next;
                    }
                }
            }
    
            private void button2_Click_1(object sender, EventArgs e)
            {
                Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);
    
                left = PublicValue.Head;
                right = PublicValue.Head;
    
                if (left == null)
                {
                    MessageBox.Show("无法排序,请先存入数据");
                }
                else
                {
                    for (; left != null; left = left.Next)//最大的数放在左边
                    {
                        right = left;
                        for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                        {
                            if (right.classnum.CompareTo(rightmin.classnum) < 0)
                            {
                                rightmin = right;
                            }
                        }
    
                        temp.id = rightmin.id;
                        temp.name = rightmin.name;
                        temp.classnum = rightmin.classnum;
                        temp.c_sharp = rightmin.c_sharp;
                        temp.ds = rightmin.ds;
                        temp.maogai = rightmin.maogai;
                        temp.ps = rightmin.ps;
                        temp.sports = rightmin.sports;
                        temp.total = rightmin.total;//补充
                        temp.average = rightmin.average;//补充
    
                        rightmin.id = left.id;
                        rightmin.name = left.name;
                        rightmin.classnum = left.classnum;
                        rightmin.c_sharp = left.c_sharp;
                        rightmin.ds = left.ds;
                        rightmin.maogai = left.maogai;
                        rightmin.ps = left.ps;
                        rightmin.sports = left.sports;
                        rightmin.total = left.total;//补充
                        rightmin.average = left.average;//补充
    
    
                        left.id = temp.id;
                        left.name = temp.name;
                        left.classnum = temp.classnum;
                        left.c_sharp = temp.c_sharp;
                        left.ds = temp.ds;
                        left.maogai = temp.maogai;
                        left.ps = temp.ps;
                        left.sports = temp.sports;
                        left.total = temp.total;//补充
                        left.average = temp.average;//补充
                    }
    
                    //输出
                    MessageBox.Show("排序成功");
                    Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
    
                    textBox1.Text = "";//先清空
                    textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
    
                    cur = PublicValue.Head;
    
                    while (cur != null)
                    {
                        textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                        cur = cur.Next;
                    }
                }
            }
    
            private void button3_Click_1(object sender, EventArgs e)
            {
                Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);
    
                left = PublicValue.Head;
                right = PublicValue.Head;
    
                if (left == null)
                {
                    MessageBox.Show("无法排序,请先存入数据");
                }
                else
                {
                    for (; left != null; left = left.Next)//最大的数放在左边
                    {
                        right = left;
                        for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                        {
                            if (right.total > rightmin.total)//从大到小 其他排序方式只改这一行即可
                            {
                                rightmin = right;
                            }
                        }
    
                        temp.id = rightmin.id;
                        temp.name = rightmin.name;
                        temp.classnum = rightmin.classnum;
                        temp.c_sharp = rightmin.c_sharp;
                        temp.ds = rightmin.ds;
                        temp.maogai = rightmin.maogai;
                        temp.ps = rightmin.ps;
                        temp.sports = rightmin.sports;
                        temp.total = rightmin.total;//补充
                        temp.average = rightmin.average;//补充
    
                        rightmin.id = left.id;
                        rightmin.name = left.name;
                        rightmin.classnum = left.classnum;
                        rightmin.c_sharp = left.c_sharp;
                        rightmin.ds = left.ds;
                        rightmin.maogai = left.maogai;
                        rightmin.ps = left.ps;
                        rightmin.sports = left.sports;
                        rightmin.total = left.total;//补充
                        rightmin.average = left.average;//补充
    
    
                        left.id = temp.id;
                        left.name = temp.name;
                        left.classnum = temp.classnum;
                        left.c_sharp = temp.c_sharp;
                        left.ds = temp.ds;
                        left.maogai = temp.maogai;
                        left.ps = temp.ps;
                        left.sports = temp.sports;
                        left.total = temp.total;//补充
                        left.average = temp.average;//补充
                    }
    
                    //输出
                    MessageBox.Show("排序成功");
                    Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
    
                    textBox1.Text = "";//先清空
                    textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
    
                    cur = PublicValue.Head;
    
                    while (cur != null)
                    {
                        textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                        cur = cur.Next;
                    }
                }
            }
    
            private void button4_Click_1(object sender, EventArgs e)
            {
                this.Close();
            }
    
            private void button5_Click_1(object sender, EventArgs e)
            {
    
                int choose = -1;//
    
                if (comboBox1.Text == "语文") choose = 0;
                else if (comboBox1.Text == "体育") choose = 1;
                else if (comboBox1.Text == "数学") choose = 2;
                else if (comboBox1.Text == "英语") choose = 3;
                else if (comboBox1.Text == "物理") choose = 4;
    
                //排序
                Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
                Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);
    
                left = PublicValue.Head;
                right = PublicValue.Head;
    
                if (left == null)
                {
                    MessageBox.Show("无法排序,请先存入数据");
                }
                else
                {
                    for (; left != null; left = left.Next)//最大的数放在左边
                    {
                        right = left;
                        for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                        {
                            switch (choose)
                            {
                                case -1:
                                    MessageBox.Show("出错了!choose=-1 没有选择");
                                    break;
                                case 0:
                                    if (right.c_sharp > rightmin.c_sharp)//从大到小
                                    {
                                        rightmin = right;
                                    }
                                    break;
                                case 1:
                                    if (right.ds > rightmin.ds)//从大到小
                                    {
                                        rightmin = right;
                                    }
                                    break;
                                case 2:
                                    if (right.maogai > rightmin.maogai)//从大到小
                                    {
                                        rightmin = right;
                                    }
                                    break;
                                case 3:
                                    if (right.ps > rightmin.ps)//从大到小
                                    {
                                        rightmin = right;
                                    }
                                    break;
                                case 4:
                                    if (right.sports > rightmin.sports)//从大到小
                                    {
                                        rightmin = right;
                                    }
                                    break;
                            }
    
                        }
    
    
                        temp.id = rightmin.id;
                        temp.name = rightmin.name;
                        temp.classnum = rightmin.classnum;
                        temp.c_sharp = rightmin.c_sharp;
                        temp.ds = rightmin.ds;
                        temp.maogai = rightmin.maogai;
                        temp.ps = rightmin.ps;
                        temp.sports = rightmin.sports;
                        temp.total = rightmin.total;//补充
                        temp.average = rightmin.average;//补充
    
                        rightmin.id = left.id;
                        rightmin.name = left.name;
                        rightmin.classnum = left.classnum;
                        rightmin.c_sharp = left.c_sharp;
                        rightmin.ds = left.ds;
                        rightmin.maogai = left.maogai;
                        rightmin.ps = left.ps;
                        rightmin.sports = left.sports;
                        rightmin.total = left.total;//补充
                        rightmin.average = left.average;//补充
    
    
                        left.id = temp.id;
                        left.name = temp.name;
                        left.classnum = temp.classnum;
                        left.c_sharp = temp.c_sharp;
                        left.ds = temp.ds;
                        left.maogai = temp.maogai;
                        left.ps = temp.ps;
                        left.sports = temp.sports;
                        left.total = temp.total;//补充
                        left.average = temp.average;//补充
                    }
    
                    //输出
                    MessageBox.Show("排序成功");
                    Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
    
                    textBox1.Text = "";//先清空
                    textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
    
                    cur = PublicValue.Head;
    
                    while (cur != null)
                    {
                        textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                        cur = cur.Next;
                    }
                }
    
            }
    
            private void SortForm_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    

    7.查找

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace C_sharp学生成绩管理系统
    {
        public partial class FindForm : Form
        {
            private Button button1;
            private TextBox textBox1;
            private TextBox textBox2;
            private Label label1;
            private Label label2;
            private Button button2;
            
            public FindForm()
            {
                InitializeComponent();
            }
            private void button1_Click_1(object sender, EventArgs e)
            {
                this.Close();
            }
           
            private void InitializeComponent()
            {
                this.button1 = new System.Windows.Forms.Button();
                this.button2 = new System.Windows.Forms.Button();
                this.textBox2 = new System.Windows.Forms.TextBox();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.label1 = new System.Windows.Forms.Label();
                this.label2 = new System.Windows.Forms.Label();
                this.SuspendLayout();
                // 
                // button1
                // 
                this.button1.BackColor = System.Drawing.SystemColors.Info;
                this.button1.Location = new System.Drawing.Point(561, 386);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(98, 51);
                this.button1.TabIndex = 0;
                this.button1.Text = "退出";
                this.button1.UseVisualStyleBackColor = false;
                this.button1.Click += new System.EventHandler(this.button1_Click_1);
                // 
                // button2
                // 
                this.button2.BackColor = System.Drawing.SystemColors.Info;
                this.button2.Location = new System.Drawing.Point(309, 31);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(115, 40);
                this.button2.TabIndex = 1;
                this.button2.Text = "查找";
                this.button2.UseVisualStyleBackColor = false;
                this.button2.Click += new System.EventHandler(this.button2_Click_1);
                // 
                // textBox2
                // 
                this.textBox2.BackColor = System.Drawing.Color.Snow;
                this.textBox2.Location = new System.Drawing.Point(103, 99);
                this.textBox2.Multiline = true;
                this.textBox2.Name = "textBox2";
                this.textBox2.Size = new System.Drawing.Size(556, 261);
                this.textBox2.TabIndex = 2;
                // 
                // textBox1
                // 
                this.textBox1.BackColor = System.Drawing.Color.Snow;
                this.textBox1.Location = new System.Drawing.Point(103, 38);
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(168, 25);
                this.textBox1.TabIndex = 3;
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(39, 38);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(37, 15);
                this.label1.TabIndex = 4;
                this.label1.Text = "学号";
                // 
                // label2
                // 
                this.label2.AutoSize = true;
                this.label2.Location = new System.Drawing.Point(39, 102);
                this.label2.Name = "label2";
                this.label2.Size = new System.Drawing.Size(37, 15);
                this.label2.TabIndex = 5;
                this.label2.Text = "信息";
                // 
                // FindForm
                // 
                this.BackColor = System.Drawing.SystemColors.InactiveCaption;
                this.ClientSize = new System.Drawing.Size(739, 449);
                this.Controls.Add(this.label2);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.textBox2);
                this.Controls.Add(this.button2);
                this.Controls.Add(this.button1);
                this.ForeColor = System.Drawing.Color.Blue;
                this.Name = "FindForm";
                this.Text = "查找";
                this.Load += new System.EventHandler(this.FindForm_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            private void button2_Click_1(object sender, EventArgs e)
            {
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
                cur = PublicValue.Head;
                int findId = int.Parse(textBox1.Text);
                textBox2.Text = "";//先清空
                textBox2.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
    
             
    
                while (cur != null)
                {
                    if (cur.id == findId)
                    {
                        textBox2.Text += cur.id + "\t";
                        textBox2.Text += cur.classnum + "\t";
                        textBox2.Text += cur.name + "\t";
                        textBox2.Text += cur.c_sharp + "\t";
                        textBox2.Text += cur.ds + "\t" + "\t";
                        textBox2.Text += cur.maogai + "\t";
                        textBox2.Text += cur.ps + "\t";
                        textBox2.Text += cur.sports + "\t";
                        textBox2.Text += cur.total + "\t";
                        textBox2.Text += cur.average.ToString("f2");
                        break;
                    }
                    cur = cur.Next;
                }
                if (cur == null)
                {
                    MessageBox.Show("你输入的学号不存在!");
                }
            }
    
            private void FindForm_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    

    ==那么先恭喜看到这里的亲,你已经快要胜利了,666. 长时间地做和用眼对身体不好,请缓解一下自己的疲劳。==看着以下图片缓解一下吧。

    在这里插入图片描述
    没办法,码农的生活就是这么枯燥且乏味,为了自己的目标和学习、工作努力有什么不值得呢。
    为了方便大家做出来,我提供了每一块的代码和控件属性表给大家,链接如下:
    链接:https://pan.baidu.com/s/1T8VV4jX0G9wxV3QIJgOCkA
    提取码:zuyc

    运行结果

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里说明一下,可能运行出来的信息界面不太规则排列,大家可以去自行更改。

    行百里者半九十,坚持练习,就会有长足的进步。加油!
    博主整理不易,还请大家多多指正,转载请注明出处。如果对你的学习有帮助的话请留下你那个大大的赞,你的支持与关注就是博主最大的更新动力。

    本期博文如果反响比较好的话,我会在评论区发放源代码链接,也请大家在评论区多多留言,谢谢大家的支持与鼓励

    C# 下期预告:
    1.简易计算器的实现
    2.C#核心语法
    3.俄罗斯方块的设计与编写
    本期源代码文件链接:
    链接:https://pan.baidu.com/s/16CJzZ_2GsmjO-fypOpgNHA
    提取码:y72z

    展开全文
  • 20个C#窗体设计实例

    2014-04-18 12:51:09
    20个超赞的C#窗体设计实例,qq窗体,自定义屏保,滚动字幕……
  • c# Windows窗体应用程序设计综合实例 ----数学测验器 在前面已经介绍了基本的几个控件的应用,并且也更新了一个小游戏的设计。步骤比较多,只要理清楚每个步骤和每块代码添加的作用,就可以顺利地完成。有什么问题...

    c# Windows窗体应用程序设计综合实例 ----数学测验器

    在前面已经介绍了基本的几个控件的应用,并且也更新了一个小游戏的设计。步骤比较多,只要理清楚每个步骤和每块代码添加的作用,就可以顺利地完成。有什么问题欢迎大家讨论私信。

    -------------------------------------------------------
    那么开始今天的正题

    新建项目

    1.打开vs2017,新建一个窗体项目,命名为“数学测验器”。将窗体size属性更改为 500 , 400 。(大小可以根据自己的需求调整)
    2.将“FormBorderStyle”属性的值更改为“Fixed3D”,并“MaximizeBox”属性设置为“False”。

    创建“剩余时间框”

    1.从“工具箱” 中添加一个 Label 控件,然后将其“(Name)” 属性的值设置为“timeLabel” 。
    2.将“AutoSize”属性更改为“False”。将“BorderStyle”属性更改为“FixedSingle”以在框的周围绘制线条。将“Size”属性设置为“200, 30”。
    3.在“属性” 窗口中,选择“Text” 属性,然后选择 Backspace 键以清除此属性的值。
    选择“Font” 属性旁边的加号 (+ ),然后将“Size” 属性的值更改为“15.75” 。
    4. 从“工具箱” 中再添加一个Label控件,然后将其字号设置为“15.75” 。将“Text”属性设置为“剩余时间”。(后面提到的字号都是在Font属性的+里面修改)

    添加加法的控件

    1.从“工具箱” 中添加一个“Label”控件,然后将其“Text” 属性设置为“?” (问号)。
    将“AutoSize”属性设置为“False”。
    将“Size”属性设置为“60, 50”。
    将字号设置为“18”。
    将“TextAlign”属性设置为“MiddleCenter”。
    将“Location”属性设置为“50, 75”。
    将“(Name)”属性设置为“plusLeftLabel”。
    将该Label控件复制粘贴三次,更改如下属性:将第二个 Label的“Text”属性值设置为 + (加号);第三个Label的“(Name)”属性值设置为“plusRightLabel”; 第四个 标签的“Text”属性值设置为 = (等于号)。
    从“工具箱” 添加一个 NumericUpDown 控件,将其字号设置为“18” ,并将其宽度设置为“100” ;将此“NumericUpDown”控件与加法题的各 Label 控件排成一行;“NumericUpDown”控件的“(Name)” 属性值更改为“sum” 。
    效果图如下:
    效果图

    添加其他运算的控件

    复制加法题的全部五个控件(四个 Label 控件和一个 NumericUpDown 控件),然后粘贴这些控件。分别更改以下属性:

    减法

    将第二个Label的“Text”属性值更改为“-”
    将第一个问号Label命名为“minusLeftLabel”
    将第二个问号Label命名为“minusRightLabel”
    将“NumericUpDown”控件命名为“difference”

    乘法

    第一个Label命名为“timesLeftLabel”
    第二个Label的“Text”属性更改为“×”(乘号)
    第三个Label命名为“timesRightLabel”,然后将 NumericUpDown 控件命名为“product”

    除法

    第一个Label命名为“dividedLeftLabel”
    第二个Label的“Text”属性更改为“÷”(除号)
    第三个Label命名为“dividedRightLabel”
    NumericUpDown 控件命名为“quotient”

    设置 Tab 键索引顺序

    从“工具箱” 添加一个 Button 控件,然后将其“(Name)” 属性设置为“startButton” 。
    “Text”属性设置为“开始测验”。将字号设置为“14”。
    将“AutoSize”属性设置为“True”,这可使此按钮自动调整大小以适合文本。
    “startButton”控件的“TabIndex”属性值设置为“1”。
    “TabIndex” 属性用于设置测验对象选择 Tab 键时的控件顺序。
    NumericUpDown sum 控件的“TabIndex”属性值设置为“2”,将 difference 控件的此属性值设置为“3”,将 product 控件的此属性值设置为“4”,将 quotient 控件的此属性值设置为“5”。
    效果图如下:
    效果图

    添加代码

    添加随机加法

    后面的代码最好都手动输入。

    public partial class Form1 : Form
    {
    int addend1;
    int addend2;
    
    Random randomizer = new Random();
    }
    
    
    添加一个名为 StartTheQuiz() 的方法,此方法使用 Random 对象的 Next() 方法在Label中显示随机数。 StartTheQuiz() 
    public void StartTheQuiz()
    {
        
        addend1 = randomizer.Next(51);
        addend2 = randomizer.Next(51);
    
       
        plusLeftLabel.Text = addend1.ToString();
        plusRightLabel.Text = addend2.ToString();
    
        
        sum.Value = 0;
    }
    
    
    

    现该行为的 Click 事件处理程序。
    添加下面两个语句。

    private void startButton_Click(object sender, EventArgs e)
    {
        StartTheQuiz();
        startButton.Enabled = false;           
    }
    
    

    运行后,当第一行出现随机加法,即设置成功。

    添加倒计时计时器

    在刚才的Form代码添加 int timeLeft;,然后添加一个Timer控件。修改“Interval”属性为“1000”。
    双击Timer控件,添加如下代码:

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (timeLeft > 0)
        {
            
            timeLeft = timeLeft - 1;
            timeLabel.Text = timeLeft + " seconds";
        }
        else
        {
            
            timer1.Stop();
            timeLabel.Text = "Time's up!";
            MessageBox.Show("You didn't finish in time.", "Sorry!");
            sum.Value = addend1 + addend2;
            startButton.Enabled = true;
        }
    }
    
    

    在刚才的StartTheQuiz()方法中添加如下代码

    timeLeft = 30;
        timeLabel.Text = "30 seconds"; 
        timer1.Start();
    
    

    运行后,计时框开始计时。

    添加 CheckTheAnswer() 方法

    为了验证用户输入的结果与正确的结果是否相等,添加以下代码。

    private bool CheckTheAnswer()
    {
        if (addend1 + addend2 == sum.Value)
            return true;
        else
            return false;
    }
    
    

    将以下代码添加到 Timer1_Tick() 方法中的 if else 语句,使计时器在用户获得正确答案时停止。

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (CheckTheAnswer())
        {
            
            timer1.Stop();
            MessageBox.Show("You got all the answers right!",
                            "Congratulations!");
            startButton.Enabled = true;
        }
        else if (timeLeft > 0)
        {
           
           timeLeft--;
            timeLabel.Text = timeLeft + " seconds";
        }
        else
        {
            
            timer1.Stop();
            timeLabel.Text = "Time's up!";
            MessageBox.Show("You didn't finish in time.", "Sorry!");
            sum.Value = addend1 + addend2;
            startButton.Enabled = true;
        }
    }
    
    

    为 NumericUpDown 控件添加 Enter 事件处理程序

    选择窗体上的第一个“NumericUpDown” 控件(名为“sum”),然后在“属性” 对话框中,选择工具栏上的“事件” 图标(闪电的形状)。选择“Enter” 事件,键入“answer_Enter”,再按 Enter 键。
    =
    在“answer_Enter” 事件处理程序的方法中,添加以下代码:

    private void answer_Enter(object sender, EventArgs e)
    {
            NumericUpDown answerBox = sender as NumericUpDown;
    
        if (answerBox != null)
        {
            int lengthOfAnswer = answerBox.Value.ToString().Length;
            answerBox.Select(0, lengthOfAnswer);
        }
    }
    
    

    在“Windows 窗体设计器” 中,选择 difference“NumericUpDown” 控件。在“属性”对话框的“事件”页中,向下滚动到“Enter”事件,选择行末尾的下拉箭头,然后选择刚才添加的 answer_Enter 事件处理程序。
    对 product 和 quotient NumericUpDown 控件重复上述步骤。
    运行后,当选择“NumericUpDown” 控件时,将自动选中现有值,然后在你开始输入其他值时自动清除现有值。

    添加减法问题

    在之前的Form窗口代码中,加入 int minuend; int subtrahend;

    接下来,将修改 StartTheQuiz() 方法,以便为减法题提供随机值。

    public void StartTheQuiz()
    {
       
        
        addend1 = randomizer.Next(51);
        addend2 = randomizer.Next(51);
    
        
        plusLeftLabel.Text = addend1.ToString();
        plusRightLabel.Text = addend2.ToString();
    
       
        sum.Value = 0;
    
           minuend = randomizer.Next(1, 101);
        subtrahend = randomizer.Next(1, minuend);
        minusLeftLabel.Text = minuend.ToString();
        minusRightLabel.Text = subtrahend.ToString();
        difference.Value = 0;
    
            timeLeft = 30;
        timeLabel.Text = "30 seconds"; 
        timer1.Start();
    }
    
    

    添加之前没有的即可。
    在此示例中,想要选择最后一个重载,因为您可以指定最小值和最大值。
    修改 CheckTheAnswer() 方法来检查减法答案是否正确。

    private bool CheckTheAnswer()
    {
        if ((addend1 + addend2 == sum.Value)
            && (minuend - subtrahend == difference.Value))
            return true;
        else
            return false;
    }
    
    
    

    将计时器 Tick 事件处理程序的最后部分替换为下面的代码,使其在时间用完时填充正确答案。

    else
    {
        
        timer1.Stop();
        timeLabel.Text = "Time's up!";
        MessageBox.Show("You didn't finish in time.", "Sorry!");
        sum.Value = addend1 + addend2;
        difference.Value = minuend - subtrahend;
        startButton.Enabled = true;
    }
    
    

    添加乘法和除法问题

    窗体class Form1 : Form代码中添加四个整型变量

    int multiplicand;
        int multiplier;
    
         
        int dividend;
        int divisor;
    

    与前面的操作一样,修改 StartTheQuiz() 方法,以便为乘法和除法题填入随机数。
    添加以下代码

     multiplicand = randomizer.Next(2, 11);
        multiplier = randomizer.Next(2, 11);
        timesLeftLabel.Text = multiplicand.ToString();
        timesRightLabel.Text = multiplier.ToString();
        product.Value = 0;
    
            divisor = randomizer.Next(2, 11);
        int temporaryQuotient = randomizer.Next(2, 11);
        dividend = divisor * temporaryQuotient;
        dividedLeftLabel.Text = dividend.ToString();
        dividedRightLabel.Text = divisor.ToString();
        quotient.Value = 0;
    
    
    

    修改 CheckTheAnswer() 方法

    private bool CheckTheAnswer()
    {
        if ((addend1 + addend2 == sum.Value)
            && (minuend - subtrahend == difference.Value)
            && (multiplicand * multiplier == product.Value)
            && (dividend / divisor == quotient.Value))
            return true;
        else
            return false;
    }
    
    

    由于使用键盘无法方便地输入乘号 (×) 和除号 (÷),因此 C# 和 Visual Basic 接受用星号 (*) 代替乘号,用斜线 (/) 代替除号。
    更改计时器 Tick 事件处理程序的最后部分,使其在时间用完时填入正确答案。

    else
    {
        
        timeLabel.Text = "Time's up!";
        MessageBox.Show("You didn't finish in time.", "Sorry");
        sum.Value = addend1 + addend2;
        difference.Value = minuend - subtrahend;
        product.Value = multiplicand * multiplier;
        quotient.Value = dividend / divisor;
        startButton.Enabled = true;
    }
    
    

    运行结果:必须回答四个问题才能完成测验。

    自定义测试

    通过设置“timeLabel”控件的“BackColor”属性,使其在测验只剩下 5 秒时变为红色 。
    timeLabel.BackColor = Color.Red;
    当测验结束时重置颜色。
    当测验参加者在 NumericUpDown 控件中输入正确答案时,通过播放声音来进行提示。 (必须为每个控件的 ValueChanged 事件编写事件处理程序,只要用户更改控件的值,就激发该事件。)

    今天的分享就到这里,欢迎大家在下方留言评论。

    展开全文
  • C#简单窗体应用程序(一)

    万次阅读 多人点赞 2017-03-12 21:24:04
    例题:创建一个Windows窗体应用程序,在窗体中添加两个按钮,当单击第一个按钮时,显示“我来啦!”,当单击第二个按钮时,显示“我走啦!”。 第一步:创建项目; 文件→新建→项目;选择“项目类型”...

    使用C#创建控制台应用程序的基本步骤:

    (1)创建项目;

    (2)用户界面设计;

    (3)属性设置;

    (4)编写程序代码;

    (5)保存、调试、运行;

     

    例题:创建一个Windows窗体应用程序,在窗体中添加两个按钮,当单击第一个按钮时,显示“我来啦!”,当单击第二个按钮时,显示“我走啦!”。

     

    第一步:创建项目;

     

                文件→新建→项目;选择“项目类型”为Visual C#,“模板”为Windows窗体应用程序;

                输入名称“例1-2”;选择存放路径“H:\C#程序”;选择“创建新解决方案”;

     

    第二步:用户界面设计;(视图→工具箱)

     

               在工具箱中双击“button”添加按钮;双击“textbox”添加文本框;

    工具箱:

    用户界面:

    第三步:属性设置;(视图→属性窗口)       

     

    控件名NameText
    Form1 第一个窗体应用程序
    Button1 按钮1
    Button2 按钮2

    设置结果:

    第四步:编写程序代码;

    (1)双击按钮1,在  private void button1_Click(object sender, EventArgs e){}中输入
               textBox1.Text=("我来了!");

    (2)双击按钮2,在private void button2_Click(object sender, EventArgs e){}中输入

               textBox1.Text = ("我走了!");

           代码如下:

    第五步:保存、调试、运行;

           单击启动调试或者F5键;

           运行结果:

    展开全文
  • c# Windows窗体应用程序设计综合实例(一)匹配游戏设计 上次的计时器运行效果图如下: = ------------------------------------------------------------------------------ 今天来分享一个综合实例,设计一个匹配...
  • c#窗体应用程序浏览本地文件夹 private void button2_Click(object sender, EventArgs e) { FolderBrowserDialog folderDialog = new FolderBrowserDialog(); //实例化一个FolderBrowserDialog对象 folderDialog...
  • @全体成员:提供据体图布局和源代码供大家参考,如有不理解的地方可以下载压缩包体验。 个人原创,仅供参考。 压缩包地址: 具体布局如下: 源代码如下: using System; using System.IO;... ...
  • c#经典编程实例(四窗体应用程序

    万次阅读 多人点赞 2013-06-15 18:13:46
    一:.NET中窗体应用程序就是一种GUI程序 窗体创建的两种方式: (1)自动生成的是: Application.Run(new Form1()); 相当于: Form1 f = new Form1(); Application.Run(f); (2)显示新的窗体 Form2 f =...
  • 摘要:C#源码,菜单窗体,窗体应用 第一个C#窗体应用程序的源码,是不是简单的要晕倒,本来就不想发上来的,不过想想那些初接触C#的菜鸟们,还是发上来吧,必竟挺基础的实例代码,对学习C#肯定有帮助。
  • 【Winform】学习笔记(一)——C# 窗体应用程序简单入门 项目中需要做一个桌面程序,计划用Winform来实现,在这里记录一下自己的学习过程。 一、什么是Winform? WinForm 是 Windows Form 的简称,是基于 .NET ...
  • c#窗体应用程序设计

    2013-06-13 11:17:58
    PPT,介绍的非常详细 ,有界面有实例,实为C#入门者之利器
  • 1.新建窗体并打开窗体 在项目文件中添加新建项,选择Windows窗体, 在Form1窗体中添加鼠标单击窗体事件,并在该事件对应的方法中写入打开 Form2 窗体的代码,点击窗体1,然后有下角点击事件,具体代码如下。 ...
  • windows窗体应用

    2018-03-29 21:13:11
    简单的窗体应用,使用C#语言,用动物和工作人员为例子
  • 文章目录绪论一.输出操作:二.输入操作三.按钮操作四.源代码分享: ...本文内容主要介绍窗体应用程序常用的输入输出+操作模块+学习感悟。 一.输出操作: Label控件 我们所说的控件其实可以理解...
  • 非常详细的窗体设计代码,了解c#窗体的入门必备,供大家看看。
  • 文章目录C#编写WinForm窗体应用程序(第四期)C# RadioButton:单选按钮控件【实例】完成选择用户权限的操作,并在消息框中显示所选的权限名。C# CheckBox【实例】完成选择用户爱好的操作,并在消息框中显示所选的...
  • C# 编写 WinForm 窗体应用程序(第一期)

    千次阅读 2021-02-20 18:55:12
    WinForm 是 Windows Form 的简称,是基于 .NET Framework 平台的客户端(PC软件)开发技术,一般使用 C# 编程。C# WinForm 编程需要创建「Windows窗体应用程序」项目。
  • C#界面编程C#界面编程 非常好!C# 应用程序 窗体美化界面编程
  • 对一些重复调用的类避免多次实例化。 对于高并发程序,需要结合线程处理方法进行解决。 二、未知原因崩溃 对于此类情况,可以添加未处理异常的事件。 static void Main(string[] args) { AppDomain.CurrentDomai
  • C# windows窗体应用程序设计 本系列最后一篇,以后不会再以博文的方式呈现。 文章目录C# windows窗体应用程序设计前言一、俄罗斯方块的实现二、步骤1.部分函数代码2.说明(分析代码时会用到)3.好的,展示完毕4....
  • C#窗体应用小例子

    2014-05-31 19:58:35
    C#窗体应用例子,有两个,一个是按上下左右键移动小球,第二个是委托的实例,创建一个发布者和两个接受者,在发布者的窗口里移动鼠标,接受者显示前十坐标的变化,还有一个接受者显示发布者的轨迹。
  • C#窗体应用实现简单音乐播放器

    千次阅读 多人点赞 2019-11-23 09:57:54
    c#窗体应用实现简单音乐播放器 1.使用工具与平台 语言:C# 工具(IDE):VS2017 应用类型:窗体应用 2.功能介绍 1.添加音乐 从本地文件中夹中过滤出mp3格式的文件,添加至播放列表中 2.播放、暂停、上下首切换 能够...
  • C#窗体应用程序--测试插件

    千次阅读 2015-07-11 16:16:07
    C#窗体应用程序–测试插件本人刚刚接触C#语言,并写了一个专门测试DLL插件的窗体应用程序。本文涉及的内容: 提示窗口 读取、设置文本框的值 中断方法的执行 获取指定路径中的文件 装入控件、获取控件信息、执行控件...
  • a += textBox1.Text + ",您好,欢迎进入C#世界!\n"; a += "您的密码是:" + textBox2.Text; if (radioButton1.Checked) a += "\n您的性别是:" + radioButton1.Text; if (radioButton2.Checked) a += "\n您的性别...
  • 简易计算器的实现(C#) 永远对新奇的事物保持“HelloWorld”的态度,向新世界问好;向新事物进发,胜利只属于敢于求知探索的人。 欢迎观看本期的博文,本期博文的目的是做一个简单的计算器,我将从布局分析、整体...
  • C#应用程序中如何实现全屏幕显示功能? 效果就像windows自带的屏幕保护程序和众多的游戏那样,无论是否设置了“将任务栏保持在其他窗口的前端”都不显示任务栏 实现方式一 在网上找来一些简单的实现方式: this....

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 19,198
精华内容 7,679
关键字:

c#窗体应用程序实例

c# 订阅