Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想添加(总和)单列中的所有值并显示到一个文本框中
您可以为此使用Leave事件。DataGridView
Leave
DataGridView
private void dataGridView1_Leave(object sender, EventArgs e) { int sum = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { sum += Convert.ToInt32(row.Cells[0].Value); } textBox1.Text = sum.ToString(); }