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

素材网站 源码网站开发企业开发

素材网站 源码,网站开发企业开发,整合营销的四个层次,推广产品的方法目录 英雄信息类 因为要在两个窗体里面调用字典,所以要写两个类来构建全局变量 添加功能 查询功能 英雄信息类 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.yayakq.cn/news/221961/

相关文章:

  • 网页怎么建设绍兴百度seo
  • 免费建站系统有哪些重庆seo网站哪家好
  • 钦州网站建设设计网站建设的任务规划
  • 手机网站自适应屏幕网页设计图纸
  • 广州网站定制开发公司哪家好网站推广塔山双喜
  • 为什么要做网站首页设计手机论坛网站
  • 网站建设及外包网上学设计的培训机构
  • 网站建设临沂企业推广文章
  • 漳州企业网站建设制作描述建设一个网站的具体步骤
  • 部门网站建设情况汇报怎么做好seo内容优化
  • 长春本地网站制作珠海建网站价格
  • 室内设计网站国外网站建设计划表
  • 简单网站建设流程免备案虚拟主机空间
  • 重庆网站制作系统网站虚拟机可以自己做吗
  • 做旅游宣传哪个网站好客户管理系统简称
  • 怎么用php自己做网站网站做友链有行业要求吗
  • excel表格做网站扎区门户网站建设
  • 网站开发及推广是怎么回事wordpress 本地打开很慢
  • 网站图片太多怎么办如何查看网站做没做301跳转
  • 北京金融网站建设凡科申请的网站和qq空间一样吗
  • 建设银行成都官网招聘网站wordpress自动抓取
  • 锋创科技园网站建设典当行网站源码
  • vue大型网站开发wordpress添加前台漂亮注册页面
  • 如何查看一个网站的所有二级域名移动端网站模板怎么做的
  • 然后建设自营网站企业邮箱邮箱
  • 邯郸哪里做网站好企业品牌网站建设多少钱
  • 免费APP 微信 网站平台查网站开发语言
  • 怎么制作网站获取他人ip唐山网站建设怎么样
  • 企业商务网站建设站酷设计网站怎样下载图片
  • 英文 科技网站深圳网站建设优化服务