使用组合框作为筛选器

本文关键字:筛选 组合 | 更新日期: 2023-09-27 18:34:39

我做了一个程序,它是一种wiki,但是在一个程序中。我添加了很多图片框,我有 3 个过滤器对这些图片框进行排序:角色、攻击类型和名称。我想做的是,如果你选择攻击类型RANGED,它会禁用其他具有与RANGED不同的攻击类型的图片框。

尝试将每个英雄(我为它制作了一个不同的类(与计时器进行比较,但我不知道该怎么做。

我也试过这个

if(comboBox1.Text == "RANGED") { //do stuff }

但是我不知道如何访问我制作的数组中的所有英雄,并检查他们是否有atkType = RANGED。

我的英雄.cs类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace WindowsFormsApplication1
{
    public struct Hero
    {
        public string Name;
        public string Role; /* carry, disabler, lane support, initiator, jungler, support, durable, nuker, pusher, escape */
        public string atkType; /* melee or ranged */
        public string Type; /* strength, agility or intelligence */
        public string imgName;
        public Hero(string name, string role, string atktype, string type, string imgname)
        {
            Name = name;
            Role = role;
            atkType = atktype;
            Type = type;
            imgName = imgname;
        }
        public static Hero[] heroes = new Hero[] { 
            new Hero() {Name = "test", Role = "", atkType = "Melee", Type = "Strength", imgName = "test" }
        };
    }
}

我已经设法让过滤器工作,但现在只有一个问题:我无法处理(图像不会卸载(当前加载的图像,也无法加载新图像。我尝试过:

 if (melee == false && ranged == false)
        {
            for (int i = 0; i < Hero.heroes.Length; i++)
            {
                imgs[i].Load("http://cdn.dota2.com/apps/dota2/images/heroes/" + Hero.heroes[i].imgName + "_sb.png");
                comboBox3.Items.Add(Hero.heroes[i].Name);
                //imgs[i].MouseHover += displayInfo(i);
            }
        }
        if (ranged == true)
        {
            for (int i = 0; i < Hero.heroes.Length && Hero.heroes[i].atkType.Contains("Ranged"); i++)
            {
                imgs[i].Image.Dispose();
                imgs[i].Load("http://cdn.dota2.com/apps/dota2/images/heroes/" + Hero.heroes[i].imgName + "_sb.png");
            }
        }

使用组合框作为筛选器

代码可能是这样的:

if(cmb.text=="goofy")
    //Code
else if(cmb.text=="mars")
   //Other code
else 
   //BLA BLA