2

コンボボックスの選択されたインデックスに問題があります。基本的に、テキストボックスの結果が 1 のときにボタン 1 を無効にしたかったのですが、問題はボタン 1 が無効になり、別のオプションを選択して有効に戻さないことです。それを行う別の方法はありますか?以下は、コーディングの一部を示しているだけです。

    double[,] arr; 
    public Form1()
    {
            arr = new double[3, 3];
            for (int i = 0; i < 2; i++)
            {
                arr[0, 0] = 1;
                arr[0, 1] = 0.79;
                arr[0, 2] = 1.17;
                arr[1, 0] = 1.26;
                arr[1, 1] = 1;
                arr[1, 2] = 1.08;
                arr[2, 0] = 0.85;
                arr[2, 1] = 0.93;
                arr[2, 2] = 1;
            }
        void CreateArray()
        {
        if (comboBox1.SelectedIndex == -1 || comboBox2.SelectedIndex == -1)
            return;
        else if (comboBox1.SelectedIndex == 1 || comboBox2.SelectedIndex == 0)
        {
            button1.Enabled = false;
        }
        else if (comboBox1.SelectedIndex == 0 || comboBox2.SelectedIndex == 1)
        {
            button1.Enabled = false;
        }
        else if (comboBox1.SelectedIndex == 1 || comboBox2.SelectedIndex == 2)
        {
            button1.Enabled = false;
        }
        else
        {
            button1.Enabled = true;
        }
4

1 に答える 1