C#只读DataGridView的一个小区启用 [英] c# readonly DataGridView with one enabled cell

查看:126
本文介绍了C#只读DataGridView的一个小区启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只读DataGridView的,我需要在某些特定的情况下doubleclicking一行之后启用一个细胞(使只读=假,并专注于当前行中这个特定的细胞(就像进入了它 - 光标应该开始闪烁)

I have readonly datagridview, I need in some specific case enable one cell after doubleclicking row (make readonly=false and make focus on this specific cell in current row (like entering it - the cursor should start to blink).

我有:

 private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
       dataGridView1.Cells[3].ReadOnly = false;
}

不过,这是行不通的。为什么呢?

But it doesn't work. Why?

推荐答案

尝试设置DataGridView的currentcell并调用BeginEdit

Try to set the currentcell of the Datagridview and call BeginEdit

 private void dataGridView1_DoubleClick(object sender, EventArgs e)
 {
    dataGridView1.Cells[3].ReadOnly = false;
    this.dataGridView1.CurrentCell = dataGridView1.Cells[3];
    dataGridView1.BeginEdit(true);
}

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.beginedit.aspx

这篇关于C#只读DataGridView的一个小区启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆