禁止DataGridView控件中添加和删除行

Posted on 2019-01-01 15:33  努力成长静待花开  阅读(848)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  DataGridView控件的AllowUserToAddRows

  AllowUserDeleteRows和ReadOnly属性

实现代码:

        private void btn_no_Click(object sender, EventArgs e)
        {
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.AllowUserToDeleteRows = false;
            dataGridView1.ReadOnly = true;
        }