更新时间:2023-02-13 16:52:26
对于当前单元格
For the current cell
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Shown += Form1_Shown;
}
private void Form1_Shown(object sender, EventArgs e)
{
dataGridView1.Rows.Add(1, "Karen", "Payne");
dataGridView1.Rows.Add(2, "Mary", "Smtim");
dataGridView1.Rows.Add(3, "Bill", "Jones");
}
private void button1_Click(object sender, EventArgs e)
{
if (dataGridView1.CurrentRow != null && dataGridView1.CurrentRow.IsNewRow) return;
dataGridView1.CurrentCell.Value = 0;
}
}