zhu_zy123 2020-08-19 20:19 采纳率: 33.3%
浏览 122
已采纳

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

图片说明
图片说明

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

  • 写回答

3条回答 默认 最新

  • 邱家健 2020-08-19 23:47
    关注

    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();
            }
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?