windowsform c#combobox不选择字节

时间:2017-10-18 03:17:19

标签: c# combobox

byte getWeapon(string weapon)
    {
        byte Weapon = 0x00;
        switch (metroComboBox3.SelectedIndex)
        {
            case 0: Weapon = 0x10; break;
            case 1: Weapon = 0x20; break;
            case 2: Weapon = 0x30; break;
        }
        return Weapon;
    }
    private void metroButton142_Click(object sender, EventArgs e)
    {//set button weapons
        byte Weapon = getWeapon (metroComboBox3.SelectedText);
        if (metroComboBox2.SelectedIndex == -1) { MessageBox.Show("Error: Please select a soldier first before proceeding, thank you.", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        else if (metroComboBox2.SelectedIndex == 0) PS3.Extension.WriteByte(0x10000000, Weapon);//S1L1
        else if (metroComboBox2.SelectedIndex == 1) PS3.Extension.WriteByte(0x20000000, Weapon);//S1L2
        else if (metroComboBox2.SelectedIndex == 2) PS3.Extension.WriteByte(0x30000000, Weapon);//S1L3           
    }

有人可以帮我修改我的代码。 它按照我想要的方式工作,但它没有从metrocombobox3中选择字节。我相信它的方式我要求选择的文本而不是项目,但我不知道如何解决这个问题。 metrocombobox 3包含字节但是当我在组合框中选择项目时它不选择该项目。 当我从combobox2中选择一些东西时,它工作正常。但它一直在写一个字节......

     byte getWeapon(string weapon)
    {
        **byte Weapon = 0x00;**
        switch (metroComboBox3.SelectedIndex)

0 个答案:

没有答案