zoukankan      html  css  js  c++  java
  • 向班级集合中添加学生信息

    实现效果:

      

    知识运用:

       System.Collections命名空间下的ArrayList集合类Add()方法

       使用了 DataGridView 控件

    实现代码:

            private void Form1_Load(object sender, EventArgs e)
            {
                ArrayList list_StudentInfo = new ArrayList();
                string students="";
                string[] arr_student, arr_studentinfo;
                list_StudentInfo.Add("张三 男 23");
                list_StudentInfo.Add("李四 女 18");
                list_StudentInfo.Add("王五 男 21");
                list_StudentInfo.Add("朱六 男 20");
                list_StudentInfo.Add("小七 女 22");
                foreach(string str in list_StudentInfo){
                    students += str+";";
                }
                arr_studentinfo = students.Split(';');
                dataGridView1.Rows.Add(5);
                for (int i = 0; i < arr_studentinfo.Length-1;i++ )  //注意Length-1
                {
                    arr_student = arr_studentinfo[i].Split(' ');
                    dataGridView1.Rows[i].Cells[0].Value=arr_student[0];
                    dataGridView1.Rows[i].Cells[1].Value=arr_student[1];
                    dataGridView1.Rows[i].Cells[2].Value = arr_student[2];
                }
            }
    
  • 相关阅读:
    网络流24题题解
    NOIP2018游记
    AGC016题解
    雅礼集训总结
    数学相关【真·NOIP】
    NOIP2018系列
    洛咕P4180 严格次小生成树
    矩阵乘法学习笔记
    一些比较神奇的思路
    点分治复习记
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10068306.html
Copyright © 2011-2022 走看看