【问题标题】:Searching for a file from when I select a row in a DataGridView using c#当我使用 c# 在 DataGridView 中选择一行时搜索文件
【发布时间】:2013-01-08 15:26:47
【问题描述】:

我正在使用 C# 在 Windows 窗体中工作。

我目前正在从事一个项目,我希望能够从我的 datagridview (DGV) 中选择一行,并从该选定的行中尝试从文件夹中找到一个 CSV 文件。

For example if I select a row from my first DGV the programme should automatically recognise that the cell in column 4 is the folder directory name of where the CSV file is located in my documents, and when that row is selected it automatically displays第二个 DGV 中的 csv 文件。

任何帮助将不胜感激。

【问题讨论】:

  • 你能更准确地说你卡在哪里吗?
  • 请显示您当前的代码,它准确地描述了您卡在哪里..相关代码总是好的..如果您希望我们为您完成您的工作,那么这对您来说不是一个好的期望部分..显示您尝试过的内容
  • 我想他想抓住点击datagridview
  • 试图在这方面有一个好的开始。我一直在网上搜索,试图找到能够从 DGV 中选择一行的信息,并从选定的行中使用单元格 4 来显示文档目录信息。单元格 4 的名称参考目录名称。

标签: c# winforms


【解决方案1】:
  1. 将处理程序附加到 DataGridView.CellMouseClick 事件Link
  2. 从 DataGridViewCellMouseEventArgs 参数中获取行索引。
  3. 从点击行内的第 4 列获取数据
  4. 打开文件并将所有数据放入第二个 DGV 中

【讨论】:

  • 谢谢。我只是有点困惑如何开始这就是我简短的原因。非常感谢。
猜你喜欢
  • 2011-09-20
  • 1970-01-01
  • 2012-08-10
  • 2014-12-05
  • 1970-01-01
  • 1970-01-01
  • 2018-10-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多