C#dataGridView中的按钮无效化,和ComBoBox相关的问题

图片说明
图片说明

求大佬帮忙解决一下图上面的2个问题

private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{

        if (e.ColumnIndex==1)
        {

            string tmpFruit = string.Empty;
            tmpFruit = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            if (tmpFruit == "苹果")
            {
                sAppleCnt += 1;
            }

            if (tmpFruit == "橘子")
            {
                sOrangeCnt += 1;
            }
            if (tmpFruit == "梨")
            {
                sPearCnt += 1;
            }

            this.txtAppleCount.Text = sAppleCnt.ToString();
            this.textBox1.Text = sPearCnt.ToString();
            this.textBox2.Text = sOrangeCnt.ToString();
        }
    }

上面的代码 不是累积 选择的个数吧 貌似是重复的设置为1
问题2:无效化 设置 disable或者readonly 试试
关闭Form2的时候 重新设置回来

把f2.Shiw()修改为 f2.ShowDialog() 不就可以了么。