datagridview - 如何获取Winform DataGridView当前行第一列的值?

标签 datagridview

这很简单,但我在谷歌搜索中找不到任何答案!

我在 C# 中尝试过这个

MessageBox.Show(this.DataGridView1.CurrentRow.Cells[0].ToString());

这会返回行和列索引,而不是单元格的值。

如何获取值?

谢谢。

最佳答案

您需要引用该值:

MessageBox.Show(this.DataGridView1.CurrentRow.Cells[0].Value.ToString());

关于datagridview - 如何获取Winform DataGridView当前行第一列的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1262250/

相关文章:

c# - 将 C# 日期时间值与 SQL Server Compact 4 日期时间进行比较

c# - 带枚举的数据绑定(bind) DatagridviewComboboxColumn

c# - 在 C#.net 中合并两个 CSV 文件的列

c# - 如何使用 SQL 查询 DataGridView?

css - 如何在 VB.net 中为 DataGridView 提供通用样式

c# - DataGridView 的总单元格数

c# - 数据 GridView 中的数据不会直观地显示 C# SQL

c# - DataGridView 选中行上下移动

c# - Index-1 没有值

c# - 如何缓存一行而不引发 "Row provided already belongs to a DataGridView"错误?