当前位置: 首页 > news >正文

软件ui成都seo培训

软件ui,成都seo培训,张家港哪家做企业网站,wordpress美文主题目录 英雄信息类 因为要在两个窗体里面调用字典,所以要写两个类来构建全局变量 添加功能 查询功能 英雄信息类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WindowsFormsApp…

目录

英雄信息类

因为要在两个窗体里面调用字典,所以要写两个类来构建全局变量

 添加功能

 查询功能


英雄信息类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
  public  class hero
    {
      public int Id;
      public string Name;
      public int Money;
      public string Type;
      public hero(int id,string name,int money,string type) {
          Id = id;
          Name = name;
          Money = money;
          Type = type;
      }
    }
}

因为要在两个窗体里面调用字典,所以要写两个类来构建全局变量

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{

    internal class Class1
    {
        public Dictionary<string ,hero > dic;

        public Class1()
        {
            dic = new Dictionary<string, hero>();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    class Class2
    {

        public static Class1 data = new Class1();
    }
}
 

 添加功能

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 WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int id = int.Parse(textBox1.Text);
            string name = textBox2.Text;
            int money = int.Parse(textBox3.Text);
            string object1 = textBox4.Text;
            hero h = new hero(id, name, money, object1);
            Class2.data.dic[name] = h;
           
            // int s = Class2.data.dic[name].Money;
          //  MessageBox.Show(s.ToString());

        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
 

 查询功能

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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }
       
        private void button2_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2();
            f.ShowDialog();
            NewMethod();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            NewMethod();
        }

        private void NewMethod()
        {
            this.dataGridView1.Rows.Clear();

            for (int i = 0; i < Class2.data.dic.Keys.Count; i++)
            {
                string nam = Class2.data.dic.Keys.ElementAt(i);

                hero h = Class2.data.dic[nam];
                DataGridViewRow row = new DataGridViewRow();

                row.CreateCells(dataGridView1);
                row.Cells[0].Value = h.Id;
                row.Cells[1].Value = h.Name;
                row.Cells[2].Value = h.Money;
                row.Cells[3].Value = h.Type;
                dataGridView1.Rows.Add(row);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text=="")
            {
                  NewMethod();
            }
            else
            {
                this.dataGridView1.Rows.Clear();
                string name = textBox1.Text;

                for (int i = 0; i < Class2.data.dic.Keys.Count; i++)
                {
                    string nam = Class2.data.dic.Keys.ElementAt(i);
                    if (nam==name)
                    {
                        hero h = Class2.data.dic[nam];
                        DataGridViewRow row = new DataGridViewRow();
                        row.CreateCells(dataGridView1);
                        row.Cells[0].Value = h.Id;
                        row.Cells[1].Value = h.Name;
                        row.Cells[2].Value = h.Money;
                        row.Cells[3].Value = h.Type;
                        dataGridView1.Rows.Add(row);
                    }                 
                }
            }
        }     
    }
}
 

http://www.dinnco.com/news/31060.html

相关文章:

  • 文案做站内网站日常维护有哪些厦门seo网站推广优化
  • 南京十大广告公司站长之家的seo综合查询工具
  • 厦门网站制作公司找哪家一件代发48个货源网站
  • 百度 网站添加seo搜索引擎优化是通过优化答案
  • 触屏版网站源码常州网站推广公司
  • 网页设计与网站建设课程考试seo研究协会网
  • 哪些网站可以做移动端模板百度明星搜索量排行榜
  • 侵入别人的网站怎么做seo推广公司价格
  • 昆明市城市建设档案馆网站手机免费建站系统
  • 学做立体书的网站软文写作
  • 中央农村工作会议指出5g网络优化
  • 做ppt模板网站百度seo收录软件
  • wordpress怎么发布网站短视频营销的优势
  • 网站页面那个图怎么做免费下载百度
  • 做web网站需要做网络通信吗培训机构哪家好
  • 做网站优化要多少钱seo优化是什么
  • php动态网站开发的基本流程网页设计排版布局技巧
  • 广州网站建设品牌公司网站设计定制
  • 十大外贸网站企业网络营销成功案例
  • o2o网站建设新闻seo收录查询工具
  • 深圳高端网站建设网页设计网络推广都需要做什么
  • 网站搭建及应用教程百度新闻网页
  • 做网站程序看什么书电商运营模式
  • 网站开发详细设计编写网页的软件
  • 亚洲男女做暖网站做网站的外包公司
  • 免费试用网站制作seo职位描述
  • 类似一起做网店的网站百度竞价推广课程
  • 怎么做网站优化小吃培训去哪里学最好
  • ssm做网站推广平台开户代理
  • 北京做网站建设公司2022适合小学生的简短新闻摘抄