【发布时间】:2014-05-29 21:34:40
【问题描述】:
我一直在尝试向我的程序添加一项功能,该功能允许您使用 OpenFileDialog 选择文件(当您双击 DataGridView 单元格时)并将该单元格的值更改为您选择的文件的路径。我不知道执行此操作的命令是什么。我试图猜测,我在互联网上查找并找不到任何东西。
Private Sub dgSound_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgSound.CellDoubleClick
If e.ColumnIndex = 3 Then 'Index of "file" column
Dim file As String = ""
OpenFileDialog1.ShowDialog()
file = OpenFileDialog1.FileName
'Contents of cell that was clicked = file
End If
End Sub
【问题讨论】:
-
e传递给事件,其中包含一些行/列信息来判断哪个被点击。 -
@Plutonix 我知道,但我不知道更改该单元格的具体命令。
-
dgSound(e.ColumnIndex, e.RowIndex).Value = "Whatever Goes Here" -
@Plutonix 谢谢!我没想到会那么容易。
标签: vb.net visual-studio-2012 datagridview