gpt4 book ai didi

c# readonly DataGridView 具有一个启用的单元格

转载 作者:行者123 更新时间:2023-11-30 22:31:23 24 4
gpt4 key购买 nike

我有只读数据 GridView ,在某些特定情况下,我需要在双击行后启用一个单元格(使 readonly=false 并将焦点放在当前行中的这个特定单元格上(如输入它 - 光标应该开始闪烁)。

我有:

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

但它不起作用。为什么?

最佳答案

dataGridView1 ReadOnly 属性应设置为 false。每行 ReadOnly 属性应设置为 true。然后您可以在需要时将单元格 ReadOnly 设置为 true。

//setting each row

foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.ReadOnly = true;
}

//setting on cell

DataGridViewCell cell = dataGridView1.Rows[e.RowIndex].Cells[3];
dataGridView1.CurrentCell = cell;
dataGridView1.CurrentCell.ReadOnly = false;
dataGridView1.BeginEdit(true);

关于c# readonly DataGridView 具有一个启用的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9268763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com