1
我正在使用DataGridView和一个导入的CSV文件,其中的值用(,)分隔 ..网格工作得很好。根据网格坐标在DataGridView中获取单元格值
我最终目标是隐藏网格出从用户视图和根据指定即(第5列中单元格的坐标网格访问数据,行6包含值“塔可“),我想将该值保存到一个变量...
最终我想循环遍历列的所有值,并将它们保存到各个变量中以便稍后使用。到目前为止,这是我...
`
Dim sReader As New StreamReader("book1.csv")
Dim Record() As String
For x As Integer = 0 To 17
DataGridView1.Columns.Add(x, x)
Next
While sReader.Peek() <> -1
Record = sReader.ReadLine().Split(",")
DataGridView1.Rows.Add(Record)
End While
Dim cellval As String
Dim col As Integer
Dim row As Integer
cellval = DataGridView1.CurrentCell.Value
col = DataGridView1.CurrentCellAddress.X
row = DataGridView1.CurrentCellAddress.Y
Label1.Text = cellval
Label2.Text = col
Label3.Text = row
`
目前,这只会在这些标签显示在列0,行0数据...
注:在for循环 17是列在我提供了..这个数字永远不变的数据量。
非常感谢提前。
** DataGridView1 [colindex] [rowindex] .FormattedValue **会给你单元格的值(坐标),那是你想要的吗? – V4Vendetta 2011-03-21 07:49:05